{"id":19989587,"url":"https://github.com/wavesoft/js-inline-loader","last_synced_at":"2026-05-25T16:06:01.402Z","repository":{"id":57283209,"uuid":"73023454","full_name":"wavesoft/js-inline-loader","owner":"wavesoft","description":"This webpack loader enables inlining functions from other modules","archived":false,"fork":false,"pushed_at":"2016-11-07T02:06:50.000Z","size":31,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-31T15:34:54.320Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wavesoft.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-11-06T22:35:39.000Z","updated_at":"2016-11-06T23:58:44.000Z","dependencies_parsed_at":"2022-09-17T12:50:54.767Z","dependency_job_id":null,"html_url":"https://github.com/wavesoft/js-inline-loader","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/wavesoft/js-inline-loader","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wavesoft%2Fjs-inline-loader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wavesoft%2Fjs-inline-loader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wavesoft%2Fjs-inline-loader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wavesoft%2Fjs-inline-loader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wavesoft","download_url":"https://codeload.github.com/wavesoft/js-inline-loader/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wavesoft%2Fjs-inline-loader/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33482467,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-25T14:31:05.219Z","status":"ssl_error","status_checked_at":"2026-05-25T14:31:02.878Z","response_time":57,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-13T04:48:32.560Z","updated_at":"2026-05-25T16:06:01.384Z","avatar_url":"https://github.com/wavesoft.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# js-inline-loader\n\n[![Module Version](https://img.shields.io/npm/v/js-inline-loader.svg?label=version\u0026maxAge=86400)](https://www.npmjs.com/package/js-inline-loader)\n\nA webpack loader than enables inlining functions from other modules\n\n## Usage\n\nCreate a node module as you would normally do:\n\n```js\nexport function staticDefinition() {\n  return {a: '1', b: '2'};\n}\n\nexport function expensiveCalculations(arg1, arg2) {\n  ...\n}\n```\n\nThen inline the functions instead of calling them, using the `%inline` macro:\n\n```js\nfunction doSomeWork() {\n\n  // Inline the return statement of a function\n  const definitions = %inline('path/to/module').staticDefinition();\n\n  ...\n\n  // Inline the function body\n  %inline('path/to/module').expensiveCalculations(arg1, arg2);\n\n  ...\n}\n```\n\nThe webpack loader will automagically expand the contents of the function you are in-lining in the location of the inline macro.\n\n## Installation\n\nFirst install the node module:\n\n```\nnpm install --save-dev js-inline-loader\n```\n\nThen install it as a preloader on webpack:\n\n```js\n  module: {\n    preLoaders: [\n      {\n        test: /.js$/,\n        exclude: /node_modules/,\n        loader: 'js-inline-loader'\n      }\n    ]\n  }\n```\n\n## Caveats\n\nThe loader will parse the javascript AST of the refered module and identify all the functions exported by it. However not all expressions are yet supported. Below you can see what is currently supported:\n\n### Will NOT work\n\nThe loader will not detect exported functions that were previously imported by other modules.\n\n```js\nimport { otherFunction } from 'path/to/module';\n\nmodule.exports = {\n  otherFunction\n}\n```\n\n### Works\n\nYou can use the classic ES6 export syntax:\n\n```js\n// As an exported function\nexport function exportedFunction() {\n  ...\n}\n\n// As a static function on the default class\nexport default class {\n  static exportedFunction2() {\n    ...\n  }\n}\n```\n\nOr the regular CommonJs syntax:\n\n```js\n// Function definition\nfunction exportedFunction() {\n\n}\n\n// Or function expression assigned to a variable\nvar exportedFunction2 = function() {\n\n}\n\n// Make sure to export your functions\nmodule.exports = {\n  exportedFunction,\n  exportedFunction2,\n\n  // You can also define functions in the object you export\n  exportedFunction3() {\n    ...\n  }\n};\n```\n\n# License\n\nCopyright (C) 2015-2016 Ioannis Charalampidis\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwavesoft%2Fjs-inline-loader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwavesoft%2Fjs-inline-loader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwavesoft%2Fjs-inline-loader/lists"}