{"id":25443905,"url":"https://github.com/aternus/babel-plugin-include","last_synced_at":"2025-08-05T22:19:00.407Z","repository":{"id":52092993,"uuid":"145051642","full_name":"Aternus/babel-plugin-include","owner":"Aternus","description":"Adds the ability to use `include` as part of the JavaScript syntax. Includes external JavaScript code inline.","archived":false,"fork":false,"pushed_at":"2023-07-21T18:01:20.000Z","size":719,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-16T01:08:58.734Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@aternus/babel-plugin-include","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Aternus.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-08-17T00:13:39.000Z","updated_at":"2023-06-25T14:57:32.000Z","dependencies_parsed_at":"2025-02-17T15:17:43.752Z","dependency_job_id":"b325eb3c-c63f-40d1-987d-182ede0308ed","html_url":"https://github.com/Aternus/babel-plugin-include","commit_stats":null,"previous_names":[],"tags_count":29,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aternus%2Fbabel-plugin-include","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aternus%2Fbabel-plugin-include/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aternus%2Fbabel-plugin-include/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aternus%2Fbabel-plugin-include/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Aternus","download_url":"https://codeload.github.com/Aternus/babel-plugin-include/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254448624,"owners_count":22072765,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":"2025-02-17T15:17:39.978Z","updated_at":"2025-05-16T01:09:14.283Z","avatar_url":"https://github.com/Aternus.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @aternus/babel-plugin-include\n\nAdds support for the `include()` function to the Babel compiler.\n\n## Why use this plugin?\n\nA simple way to organize and reuse code.\n\nThe goal of this plugin is to allow a \"native\" way of including JavaScript code\ninline - at compilation time.\n\n## Installation\n\n```bash\nnpm install -D @aternus/babel-plugin-include @babel/core @babel/cli\n```\n\n### `.babelrc.json` / `babel.config.json` (Recommended)\n\n```json\n{\n  \"plugins\": [\"@aternus/babel-plugin-include\"]\n}\n```\n\n## Usage\n\nThe `include()` function takes an argument, a file path, e.g. `file.js`.\n\n## Code\n\n### `main.js`\n\n```javascript\ninclude('welcome.js');\ninclude('stateManager.js');\n```\n\n### `welcome.js`\n\n```javascript\nconsole.log('Welcome code');\n```\n\n### `stateManager.js`\n\n```javascript\nconsole.log('State manager code');\n```\n\n### Result after compilation with Babel\n\n```javascript\nconsole.log('Welcome code');\nconsole.log('State manager code');\n```\n\n## FAQ\n\n- The `include()` function takes a single string as an argument. Following\n  arguments are ignored.\n- The included file must be a valid JavaScript file. If there are errors the\n  compiler will throw an error.\n- The default encoding is assumed to be `utf8`.\n- You can use relative and absolute filenames, and change the `root` directory\n  in plugin options.\n\n---\n\n## Programmatic Invocation\n\n### Node API\n\n```javascript\nconst transformedCode = require('@babel/core').transform(code, {\n  plugins: ['@aternus/babel-plugin-include'],\n});\n```\n\n### CLI\n\n```bash\nnpx babel --plugins @aternus/babel-plugin-include main.js\n```\n\n## Integrations\n\n### IDEs / TypeScript\n\nThe plugin ships with TypeScript types which the IDEs and TypeScript can use to\nunderstand the new `include` syntax capability without you having to take any\naction.\n\n⚠ Keep in mind that you'll still need to use Babel as the transpiler (this is a\nbabel plugin after all 😅)\n\n### ESLint\n\nThe plugin ships with an ESLint config you can extend to avoid getting errors\nabout `include` being undefined.\n\nIn your `.eslintrc.js`:\n\n```javascript\nmodule.exports = {\n  extends: [\n    // ...\n    './node_modules/@aternus/babel-plugin-include/eslint',\n  ],\n  // ...\n};\n```\n\n⚠ `./node_modules` is required to ensure that ESLint won't add \"eslint-config\"\nto the package name, resulting in a wrong path.\n\n## Options\n\nYou can provide an options object to modify the default behavior of the plugin.\n\n```javascript\n{\n  plugins: [['@aternus/babel-plugin-include', options]];\n}\n```\n\n### The following options are available:\n\n| Option Name | Type             | Default             | Notes                                                                     |\n| ----------- | ---------------- | ------------------- | ------------------------------------------------------------------------- |\n| `root`      | `string`         | `cwd()` of the file | The root directory from which all files will be included.                 |\n| `encoding`  | `BufferEncoding` | `utf-8`             | The encoding option specifies which encoding to use when including files. |\n\n## Credits\n\n[vihanb](https://github.com/vihanb) for the original package (no longer\nmaintained).\n\n## License\n\nReleased under the MIT License - see `LICENSE.md` for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faternus%2Fbabel-plugin-include","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faternus%2Fbabel-plugin-include","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faternus%2Fbabel-plugin-include/lists"}