{"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,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","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,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}