{"id":18862785,"url":"https://github.com/eik-lib/webpack-plugin","last_synced_at":"2026-06-08T06:01:21.725Z","repository":{"id":36990021,"uuid":"446930698","full_name":"eik-lib/webpack-plugin","owner":"eik-lib","description":"Webpack plugin to do build-time import mapping using Eik","archived":false,"fork":false,"pushed_at":"2025-04-10T11:38:06.000Z","size":154,"stargazers_count":0,"open_issues_count":3,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-10T12:54:20.629Z","etag":null,"topics":["eik","eik-import-mapping","webpack-plugin"],"latest_commit_sha":null,"homepage":"https://eik.dev","language":"JavaScript","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/eik-lib.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","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":"2022-01-11T18:09:06.000Z","updated_at":"2025-04-01T12:34:38.000Z","dependencies_parsed_at":"2024-06-28T19:24:53.569Z","dependency_job_id":"cb220d57-7cec-4265-9911-1646e9ceb840","html_url":"https://github.com/eik-lib/webpack-plugin","commit_stats":{"total_commits":118,"total_committers":5,"mean_commits":23.6,"dds":0.6271186440677966,"last_synced_commit":"edee12d44ddc30d85a9882c361c20ab7bcde8511"},"previous_names":[],"tags_count":49,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eik-lib%2Fwebpack-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eik-lib%2Fwebpack-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eik-lib%2Fwebpack-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eik-lib%2Fwebpack-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eik-lib","download_url":"https://codeload.github.com/eik-lib/webpack-plugin/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248886310,"owners_count":21177643,"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":["eik","eik-import-mapping","webpack-plugin"],"created_at":"2024-11-08T04:35:43.606Z","updated_at":"2026-02-23T07:51:32.155Z","avatar_url":"https://github.com/eik-lib.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @eik/webpack-plugin\n\nPlugin to rewrite bare imports to URLs as defined in import maps\n\nWebPack [Eik](https://eik.dev/) plugin to support the use of import maps to map \"bare\" import specifiers in ES modules.\n\n## Installation\n\n```bash\nnpm install @eik/webpack-plugin\n```\n\n## Usage\n\n```js\nexport default {\n\texperiments: {\n\t\toutputModule: true,\n\t},\n\tentry: \"/src/input.js\",\n\tmode: \"production\",\n\toutput: {\n\t\tenvironment: {\n\t\t\tmodule: true,\n\t\t},\n\t\tfilename: \"bundle.js\",\n\t\tpath: \"/out/\",\n\t},\n\tmodule: {\n\t\trules: [\n\t\t\t{\n\t\t\t\ttest: /\\.js$/,\n\t\t\t\tuse: {\n\t\t\t\t\tloader: \"@eik/webpack-plugin\",\n\t\t\t\t\toptions: {\n\t\t\t\t\t\tpath: \"/path/to/eik-json-folder\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t},\n};\n```\n\n## Description\n\nThis plugin transforms \"bare\" import specifiers to absolute URL specifiers in\nES modules. The module refered to by the \"bare\" import specifier will be\ntreated as external and its source will not be included in the bundle but\nrefered to by URL.\n\nThe plugin will attempt to read import map URLs from `eik.json` if present.\n\nThe path to the location of an `eik.json` file can be specified with the `path` option.\n\n```js\nexport default {\n\t//...\n\tmodule: {\n\t\trules: [\n\t\t\t{\n\t\t\t\ttest: /\\.js$/,\n\t\t\t\tuse: {\n\t\t\t\t\tloader: \"@eik/webpack-plugin\",\n\t\t\t\t\toptions: {\n\t\t\t\t\t\tpath: \"/path/to/eik-json-folder\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t},\n};\n```\n\nThe plugin can also be told which URLs to load import maps from directly using the `urls` option.\n\n```js\nexport default {\n\t//...\n\tmodule: {\n\t\trules: [\n\t\t\t{\n\t\t\t\ttest: /\\.js$/,\n\t\t\t\tuse: {\n\t\t\t\t\tloader: \"@eik/webpack-plugin\",\n\t\t\t\t\toptions: {\n\t\t\t\t\t\turls: [\"http://myserver/import-map\"],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t},\n};\n```\n\nAdditionally, individual mappings can be specified using the `maps` option.\n\n```js\nexport default {\n\t//...\n\tmodule: {\n\t\trules: [\n\t\t\t{\n\t\t\t\ttest: /\\.js$/,\n\t\t\t\tuse: {\n\t\t\t\t\tloader: \"@eik/webpack-plugin\",\n\t\t\t\t\toptions: {\n\t\t\t\t\t\tmaps: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\timports: {\n\t\t\t\t\t\t\t\t\t\"lit-element\": \"https://cdn.eik.dev/lit-element/v2\",\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t},\n};\n```\n\nIf several of these options are used, `maps` takes precedence over `urls` which takes precedence over values loaded from an `eik.json` file.\n\nie. in the following example\n\n```js\nexport default {\n\t//...\n\tmodule: {\n\t\trules: [\n\t\t\t{\n\t\t\t\ttest: /\\.js$/,\n\t\t\t\tuse: {\n\t\t\t\t\tloader: \"@eik/webpack-plugin\",\n\t\t\t\t\toptions: {\n\t\t\t\t\t\tpath: \"/path/to/eik-json-folder\",\n\t\t\t\t\t\turls: [\"http://myserver/import-map\"],\n\t\t\t\t\t\tmaps: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\timports: {\n\t\t\t\t\t\t\t\t\t\"lit-element\": \"https://cdn.eik.dev/lit-element/v2\",\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t},\n};\n```\n\nAny import map URLs in `eik.json` will be loaded first, then merged with (and overridden if necessary by) the result of fetching from `http://myserver/import-map` before finally being merged with (and overriden if necessary by) specific mappings defined in `maps`. (In this case `lit-element`)\n\n### Plugin result\n\nBundles will have bare imports mapped to absolute URLs.\n\nIe. Something like this...\n\n```js\nimport { LitElement, html, css } from \"lit-element\";\n```\n\nWill be mapped to something like this...\n\n```js\nimport { LitElement, html, css } from \"https://cdn.eik.dev/lit-element/v2\";\n```\n\n## Options\n\nThis plugin takes the following options:\n\n| option | default        | type     | required | details                                 |\n| ------ | -------------- | -------- | -------- | --------------------------------------- |\n| path   | `cwd/eik.json` | `string` | `false`  | Path to eik.json file.                  |\n| urls   | `[]`           | `array`  | `false`  | Array of import map URLs to fetch from. |\n| maps   | `[]`           | `array`  | `false`  | Array of import map as objects.         |\n\n## Note on ESM with WebPack\n\nThis plugin will only apply import maps to ESM modules. Due to this its more or less given that the source of your build must be ESM and that your build output is ESM. WebPack does **not** by default output ESM so this needs to be configured.\n\nYou enable ESM output in WebPack as follows ([reference](https://webpack.js.org/configuration/output/#outputmodule)):\n\n```js\nexport default {\n\t//...\n\texperiments: {\n\t\toutputModule: true,\n\t},\n\toutput: {\n\t\tenvironment: {\n\t\t\tmodule: true,\n\t\t},\n\t},\n};\n```\n\n## License\n\nSee license file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feik-lib%2Fwebpack-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feik-lib%2Fwebpack-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feik-lib%2Fwebpack-plugin/lists"}