Registry / devops / rollup-plugin-url-resolve

rollup-plugin-url-resolve

JSON →
library0.2.0jsnpmunverified

Rollup plugin that resolves import specifiers as URLs, allowing you to fetch dependencies directly from CDNs (e.g., unpkg, jsdelivr) or local files instead of using npm/yarn. Version 0.2.0 is the latest stable release. It supports https, http, file, and data URL protocols. Designed as an alternative to rollup-plugin-node-resolve for URL-based imports. No breaking changes or significant release cadence; the package is minimal and stable. Options are passed through to make-fetch-happen for HTTP caching, retries, and proxy support. Works alongside rollup-plugin-commonjs for CommonJS URLs. Essential for projects that want to avoid a full install step.

npm install rollup-plugin-url-resolve
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-URL-
R
rollup-plugin-url-resolve
devopsjavascriptv0.2.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
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
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

urlResolve
import urlResolve from 'rollup-plugin-url-resolve'
import { urlResolve } from 'rollup-plugin-url-resolve'
Default export only; named export is not available.
urlResolve
const urlResolve = require('rollup-plugin-url-resolve')
const { urlResolve } = require('rollup-plugin-url-resolve')
CommonJS requires the default export, not destructured.
urlResolve
import urlResolve from 'rollup-plugin-url-resolve'
import * as urlResolve from 'rollup-plugin-url-resolve'
Namespace import is not the intended usage; use default import.

Configures Rollup to use URL-based imports from unpkg with caching and CommonJS support for non-module URLs.

// rollup.config.js import urlResolve from 'rollup-plugin-url-resolve'; import commonjs from 'rollup-plugin-commonjs'; export default { input: 'src/index.js', output: { file: 'dist/bundle.js', format: 'esm' }, plugins: [ urlResolve({ cacheManager: '.cache' }), commonjs({ include: /^https:\/\/unpkg\.com/, exclude: /^https:\/\/unpkg\.com.*?\?.*?\bmodule\b/ }) ] };
Debug
Known issues
gotchaWhen using CommonJS URLs, you must include rollup-plugin-commonjs and configure it to treat those URLs as CommonJS, otherwise imports may result in 'Unexpected token' errors.
fix
Add commonjs include for the URL domain; see docs for example.
affects: >=0.1.0
gotchaThe plugin does not support node_modules resolution; it is not a drop-in replacement for @rollup/plugin-node-resolve. Only absolute URLs (https, http, file, data) are resolved.
fix
Use @rollup/plugin-node-resolve if you need to resolve local node_modules packages.
affects: >=0.0.0
gotchaCaching with cacheManager uses make-fetch-happen's cache; make sure the directory is writable and .gitignore it if needed.
fix
Set cacheManager to a path like '.cache' and add to .gitignore.
affects: >=0.1.0
Errors
Common errors & fixes
Error: Cannot find module 'foo' from 'src/bar.js'
Import specifier 'foo' is not a URL and plugin cannot resolve it.
fix
Change import to a full URL, e.g., 'https://unpkg.com/foo?module'.
Error: Unexpected token (Note that you need plugins to import files that are not JavaScript)
Imported URL returns CommonJS and rollup-plugin-commonjs is not configured to handle it.
fix
Add commonjs plugin with include pattern for the URL domain.
fetch failed: getaddrinfo ENOTFOUND unpkg.com
Network error: cannot reach the remote URL.
fix
Check internet connection, or use a different CDN like cdn.jsdelivr.net.
Upgrade
Version history
0.2.0latest on npm
Audit
Dependencies
rollupoptionalpeer dependency; this is a Rollup plugin
Agent activity
12 hits · last 30 days
node
10
OpenAI (training)
1
Resources
rollup-plugin-url-resolve — npm install rollup-plugin-url-resolve · libregistry