Registry /
http-networking / rollup-plugin-esm-import-to-url
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–223 runs
build_error
glibcnode 18–223 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
default
✓ import esmImportToUrl from 'rollup-plugin-esm-import-to-url'
✗ const esmImportToUrl = require('rollup-plugin-esm-import-to-url')
Package exports a default export. CommonJS require would not work for v2+ as it's ESM-only.
esmImportToUrl
✓ import esmImportToUrl from 'rollup-plugin-esm-import-to-url'
✗ import { esmImportToUrl } from 'rollup-plugin-esm-import-to-url'
Default export, not named. Named import will result in undefined.
Rollup plugins array entry
✓ esmImportToUrl({ imports: { 'pkg': 'https://cdn.example.com/pkg.js' } })
✗ esmImportToUrl({ 'pkg': 'https://cdn.example.com/pkg.js' })
Options must be wrapped in object with `imports` key; incorrect to pass direct property mapping.
Configures Rollup to replace bare import 'lit-element' with a CDN URL in the ESM output bundle.
// rollup.config.js
import esmImportToUrl from 'rollup-plugin-esm-import-to-url';
export default {
input: 'src/main.js',
plugins: [
esmImportToUrl({
imports: {
'lit-element': 'https://cdn.jsdelivr.net/npm/lit-element@2.4.0/lit-element.js',
},
}),
],
output: {
file: 'dist/bundle.js',
format: 'esm',
},
};
Errors
Common errors & fixes
Error: The following imports are both in the import map and in Rollup's external list: ["lit-element"]
Duplicate declaration: import specifier appears in both `external` and plugin's `imports`.
fixRemove the specifier from Rollup's `external` option and rely on the plugin.
Error: [plugin:esm-import-to-url] Could not resolve import 'lit-element'
Bare import specifier is not mapped in `imports` option and not otherwise resolved.
fixAdd the specifier to `imports` in plugin options.
ReferenceError: require is not defined (when using CommonJS require)
Package is ESM-only; using `require()` in Node.js <13 or without ESM support fails.
fixUse `import` syntax or ensure Node.js version supports ESM.
Audit
Dependencies
rolluprequiredThis is a Rollup plugin; Rollup is a peer dependency.