{"id":22012,"library":"rollup-plugin-esm-import-to-url","title":"rollup-plugin-esm-import-to-url","description":"A Rollup plugin that transforms bare import specifiers (e.g., 'lit-element') into absolute URLs for ES module output. Suitable for CDN loading or micro-frontends. Current version 2.1.0. Release pattern is ad-hoc. Differentiators: integrates with Rollup's resolve pipeline, ensures bare imports are replaced only when mapped, and throws if specifiers are also listed in Rollup's external option.","status":"active","version":"2.1.0","language":"javascript","source_language":"en","source_url":"https://github.com/trygve-lie/rollup-plugin-esm-import-to-url","tags":["javascript","rollup-plugin","rollup.js","rollup","import","url","esm"],"install":[{"cmd":"npm install rollup-plugin-esm-import-to-url","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-esm-import-to-url","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-esm-import-to-url","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"This is a Rollup plugin; Rollup is a peer dependency.","package":"rollup","optional":false}],"imports":[{"note":"Package exports a default export. CommonJS require would not work for v2+ as it's ESM-only.","wrong":"const esmImportToUrl = require('rollup-plugin-esm-import-to-url')","symbol":"default","correct":"import esmImportToUrl from 'rollup-plugin-esm-import-to-url'"},{"note":"Default export, not named. Named import will result in undefined.","wrong":"import { esmImportToUrl } from 'rollup-plugin-esm-import-to-url'","symbol":"esmImportToUrl","correct":"import esmImportToUrl from 'rollup-plugin-esm-import-to-url'"},{"note":"Options must be wrapped in object with `imports` key; incorrect to pass direct property mapping.","wrong":"esmImportToUrl({ 'pkg': 'https://cdn.example.com/pkg.js' })","symbol":"Rollup plugins array entry","correct":"esmImportToUrl({ imports: { 'pkg': 'https://cdn.example.com/pkg.js' } })"}],"quickstart":{"code":"// rollup.config.js\nimport esmImportToUrl from 'rollup-plugin-esm-import-to-url';\n\nexport default {\n  input: 'src/main.js',\n  plugins: [\n    esmImportToUrl({\n      imports: {\n        'lit-element': 'https://cdn.jsdelivr.net/npm/lit-element@2.4.0/lit-element.js',\n      },\n    }),\n  ],\n  output: {\n    file: 'dist/bundle.js',\n    format: 'esm',\n  },\n};","lang":"javascript","description":"Configures Rollup to replace bare import 'lit-element' with a CDN URL in the ESM output bundle."},"warnings":[{"fix":"Remove the specifier from `external` or ensure it is not duplicated.","message":"If a bare import specifier is also listed in Rollup's `external` option, the plugin will throw an error.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Set `output.format` to 'esm'.","message":"Output must be formatted as 'esm' (ES modules). Other formats like 'cjs' or 'iife' will cause incorrect behavior or errors.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Upgrade Node.js to v10 or later.","message":"Requires Node.js version >=10. Older versions may fail.","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"Ensure all external bare imports are explicitly mapped.","message":"Plugin only transforms bare import specifiers that are mapped in the `imports` option; other bare imports remain unchanged and may fail at runtime.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'2.1.0':37 'absolut':21 'ad':42 'ad-hoc':41 'also':64 'bare':13,52 'cdn':29 'current':35 'differenti':44 'e.g':16 'element':19 'ensur':51 'es':24 'esm':4,79 'extern':69 'frontend':34 'hoc':43 'import':5,14,53,77 'integr':45 'javascript':71 'list':65 'lit':18 'lit-el':17 'load':30 'map':58 'micro':33 'micro-frontend':32 'modul':25 'option':70 'output':26 'pattern':39 'pipelin':50 'plugin':3,10,74 'releas':38 'replac':55 'resolv':49 'rollup':2,9,47,67,73,76 'rollup-plugin':72 'rollup-plugin-esm-import-to-url':1 'rollup.js':75 'specifi':15,62 'suitabl':27 'throw':60 'transform':12 'url':7,22,78 'version':36","created_at":"2026-04-27T17:02:55.814327+00:00","updated_at":"2026-04-27T17:02:55.814327+00:00","problems":[{"fix":"Remove the specifier from Rollup's `external` option and rely on the plugin.","cause":"Duplicate declaration: import specifier appears in both `external` and plugin's `imports`.","error":"Error: The following imports are both in the import map and in Rollup's external list: [\"lit-element\"]"},{"fix":"Add the specifier to `imports` in plugin options.","cause":"Bare import specifier is not mapped in `imports` option and not otherwise resolved.","error":"Error: [plugin:esm-import-to-url] Could not resolve import 'lit-element'"},{"fix":"Use `import` syntax or ensure Node.js version supports ESM.","cause":"Package is ESM-only; using `require()` in Node.js <13 or without ESM support fails.","error":"ReferenceError: require is not defined (when using CommonJS require)"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/trygve-lie/rollup-plugin-esm-import-to-url","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/rollup-plugin-esm-import-to-url","openapi_spec":null,"status_page":null,"smithery":null,"categories":["http-networking","web-framework"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-18","next_check":"2026-07-26","install_tag":null}}