{"id":13447664,"url":"https://github.com/mjackson/rollup-plugin-url-resolve","last_synced_at":"2025-09-22T18:18:38.039Z","repository":{"id":50219216,"uuid":"191302278","full_name":"mjackson/rollup-plugin-url-resolve","owner":"mjackson","description":"Use URLs in your Rollup imports","archived":false,"fork":false,"pushed_at":"2021-06-03T22:55:57.000Z","size":192,"stargazers_count":135,"open_issues_count":5,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-05-01T21:30:05.002Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mjackson.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-06-11T05:46:36.000Z","updated_at":"2024-03-22T16:37:42.000Z","dependencies_parsed_at":"2022-09-24T08:40:37.326Z","dependency_job_id":null,"html_url":"https://github.com/mjackson/rollup-plugin-url-resolve","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjackson%2Frollup-plugin-url-resolve","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjackson%2Frollup-plugin-url-resolve/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjackson%2Frollup-plugin-url-resolve/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjackson%2Frollup-plugin-url-resolve/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mjackson","download_url":"https://codeload.github.com/mjackson/rollup-plugin-url-resolve/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":233265462,"owners_count":18650037,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T05:01:23.827Z","updated_at":"2025-09-22T18:18:32.987Z","avatar_url":"https://github.com/mjackson.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"## rollup-plugin-url-resolve\n\nThe goal of this plugin is to avoid the need to use `npm` or `yarn` clients to explicitly install your dependencies from the registry before you bundle. Instead of specifying your dependencies in `package.json`, you specify them in your source code as [URLs](https://url.spec.whatwg.org/#absolute-url-with-fragment-string) in `import` statements. Then Rollup dynamically fetches and includes those dependencies when you bundle.\n\nFor example, you could put the following in your `rollup.config.js`:\n\n```js\nimport urlResolve from 'rollup-plugin-url-resolve';\n\nexport default {\n  // ...\n  plugins: [urlResolve()]\n};\n```\n\nThen, in your source files, you can do stuff like this:\n\n```js\nimport * as d3 from 'https://unpkg.com/d3?module';\n```\n\nRun `rollup`, and you're done. No more `npm install`! :) Well, at least not for your app's dependencies.\n\nCurrently, the following URL protocols are supported:\n\n- `https:` and `http:`\n- `file:`\n- `data:`\n\nIt might help to think about this plugin as an alternative to [`rollup-plugin-node-resolve`](https://www.npmjs.com/package/rollup-plugin-node-resolve), but for any URL, not just stuff you've already installed in `node_modules`.\n\n### Options\n\nThe `urlResolve` function accepts all the same options as [`make-fetch-happen`](https://www.npmjs.com/package/make-fetch-happen). They are used when we need to `fetch` a module from a remote URL. One option that is particularly useful is `cacheManager`, which can be used to cache the results of `fetch` operations on disk. This can make your builds a lot faster if many of your URLs point to remote servers.\n\n```js\nimport urlResolve from 'rollup-plugin-url-resolve';\n\nexport default {\n  // ...\n  plugins: [\n    urlResolve({\n      // Caches the results of all fetch operations\n      // in a local directory named \".cache\"\n      cacheManager: '.cache'\n    })\n  ]\n};\n```\n\nThere are various other options as well, including support for retrying failed requests and proxy servers. Please see [the list of options](https://www.npmjs.com/package/make-fetch-happen#extra-options) for more information.\n\n### Using CommonJS\n\nYou could also try using a URL that returns CommonJS, though you won't get the benefit of tree-shaking that using JavaScript modules provides. Still, it can be a useful stopgap until a package you need starts publishing JavaScript modules.\n\nIf you do this, you'll probably want to use [`rollup-plugin-commonjs`](https://www.npmjs.com/package/rollup-plugin-commonjs) on those URLs in your Rollup config, just like you would normally do for stuff in `node_modules`:\n\n```js\nimport commonjs from 'rollup-plugin-commonjs';\nimport urlResolve from 'rollup-plugin-url-resolve';\n\nexport default {\n  // ...\n  plugins: [\n    urlResolve(),\n    commonjs({\n      // Treat unpkg URLs as CommonJS\n      include: /^https:\\/\\/unpkg\\.com/,\n      // ...except for unpkg ?module URLs\n      exclude: /^https:\\/\\/unpkg\\.com.*?\\?.*?\\bmodule\\b/\n    })\n  ]\n};\n```\n\n### License\n\n[MIT](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmjackson%2Frollup-plugin-url-resolve","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmjackson%2Frollup-plugin-url-resolve","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmjackson%2Frollup-plugin-url-resolve/lists"}