{"id":22275,"library":"rollup-plugin-url-resolve","title":"rollup-plugin-url-resolve","description":"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.","status":"active","version":"0.2.0","language":"javascript","source_language":"en","source_url":"https://github.com/mjackson/rollup-plugin-url-resolve","tags":["javascript"],"install":[{"cmd":"npm install rollup-plugin-url-resolve","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-url-resolve","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-url-resolve","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency; this is a Rollup plugin","package":"rollup","optional":true}],"imports":[{"note":"Default export only; named export is not available.","wrong":"import { urlResolve } from 'rollup-plugin-url-resolve'","symbol":"urlResolve","correct":"import urlResolve from 'rollup-plugin-url-resolve'"},{"note":"CommonJS requires the default export, not destructured.","wrong":"const { urlResolve } = require('rollup-plugin-url-resolve')","symbol":"urlResolve","correct":"const urlResolve = require('rollup-plugin-url-resolve')"},{"note":"Namespace import is not the intended usage; use default import.","wrong":"import * as urlResolve from 'rollup-plugin-url-resolve'","symbol":"urlResolve","correct":"import urlResolve from 'rollup-plugin-url-resolve'"}],"quickstart":{"code":"// rollup.config.js\nimport urlResolve from 'rollup-plugin-url-resolve';\nimport commonjs from 'rollup-plugin-commonjs';\n\nexport default {\n  input: 'src/index.js',\n  output: {\n    file: 'dist/bundle.js',\n    format: 'esm'\n  },\n  plugins: [\n    urlResolve({\n      cacheManager: '.cache'\n    }),\n    commonjs({\n      include: /^https:\\/\\/unpkg\\.com/,\n      exclude: /^https:\\/\\/unpkg\\.com.*?\\?.*?\\bmodule\\b/\n    })\n  ]\n};","lang":"typescript","description":"Configures Rollup to use URL-based imports from unpkg with caching and CommonJS support for non-module URLs."},"warnings":[{"fix":"Add commonjs include for the URL domain; see docs for example.","message":"When 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.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Use @rollup/plugin-node-resolve if you need to resolve local node_modules packages.","message":"The 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.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Set cacheManager to a path like '.cache' and add to .gitignore.","message":"Caching with cacheManager uses make-fetch-happen's cache; make sure the directory is writable and .gitignore it if needed.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Change import to a full URL, e.g., 'https://unpkg.com/foo?module'.","cause":"Import specifier 'foo' is not a URL and plugin cannot resolve it.","error":"Error: Cannot find module 'foo' from 'src/bar.js'"},{"fix":"Add commonjs plugin with include pattern for the URL domain.","cause":"Imported URL returns CommonJS and rollup-plugin-commonjs is not configured to handle it.","error":"Error: Unexpected token (Note that you need plugins to import files that are not JavaScript)"},{"fix":"Check internet connection, or use a different CDN like cdn.jsdelivr.net.","cause":"Network error: cannot reach the remote URL.","error":"fetch failed: getaddrinfo ENOTFOUND unpkg.com"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}