{"id":15393021,"url":"https://github.com/shgysk8zer0/rollup-import","last_synced_at":"2026-01-23T20:04:49.064Z","repository":{"id":164040370,"uuid":"639492407","full_name":"shgysk8zer0/rollup-import","owner":"shgysk8zer0","description":"A RollUp plugin for importing modules","archived":false,"fork":false,"pushed_at":"2025-12-27T18:10:17.000Z","size":733,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-29T16:53:37.402Z","etag":null,"topics":["import-map","node","rollup-plugin"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@shgysk8zer0/rollup-import","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/shgysk8zer0.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"shgysk8zer0","liberapay":"shgysk8zer0"}},"created_at":"2023-05-11T15:02:39.000Z","updated_at":"2025-12-27T18:10:19.000Z","dependencies_parsed_at":null,"dependency_job_id":"f783baa9-1fc8-4326-bff8-6b1881bfb83b","html_url":"https://github.com/shgysk8zer0/rollup-import","commit_stats":{"total_commits":83,"total_committers":2,"mean_commits":41.5,"dds":0.4698795180722891,"last_synced_commit":"48bac96f012bb804e8954899a9926f05f3ddcf4b"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"purl":"pkg:github/shgysk8zer0/rollup-import","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shgysk8zer0%2Frollup-import","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shgysk8zer0%2Frollup-import/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shgysk8zer0%2Frollup-import/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shgysk8zer0%2Frollup-import/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shgysk8zer0","download_url":"https://codeload.github.com/shgysk8zer0/rollup-import/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shgysk8zer0%2Frollup-import/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28699372,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-23T17:25:48.045Z","status":"ssl_error","status_checked_at":"2026-01-23T17:25:47.153Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["import-map","node","rollup-plugin"],"created_at":"2024-10-01T15:17:17.655Z","updated_at":"2026-01-23T20:04:49.059Z","avatar_url":"https://github.com/shgysk8zer0.png","language":"JavaScript","funding_links":["https://github.com/sponsors/shgysk8zer0","https://liberapay.com/shgysk8zer0","https://liberapay.com/shgysk8zer0/donate"],"categories":[],"sub_categories":[],"readme":"# rolllup-import\nA RollUp plugin for importing modules from URLs, paths, and \"bare specifiers\" using\nimport maps. You'll no longer need to `npm i` everything you need in front-end code.\n\n- - -\n[![CodeQL](https://github.com/shgysk8zer0/rollup-import/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/shgysk8zer0/rollup-import/actions/workflows/codeql-analysis.yml)\n![Node CI](https://github.com/shgysk8zer0/rollup-import/workflows/Node%20CI/badge.svg)\n![Lint Code Base](https://github.com/shgysk8zer0/rollup-import/workflows/Lint%20Code%20Base/badge.svg)\n\n[![GitHub license](https://img.shields.io/github/license/shgysk8zer0/rollup-import.svg)](https://github.com/shgysk8zer0/rollup-import/blob/master/LICENSE)\n[![GitHub last commit](https://img.shields.io/github/last-commit/shgysk8zer0/rollup-import.svg)](https://github.com/shgysk8zer0/rollup-import/commits/master)\n[![GitHub release](https://img.shields.io/github/release/shgysk8zer0/rollup-import?logo=github)](https://github.com/shgysk8zer0/rollup-import/releases)\n[![GitHub Sponsors](https://img.shields.io/github/sponsors/shgysk8zer0?logo=github)](https://github.com/sponsors/shgysk8zer0)\n\n[![npm](https://img.shields.io/npm/v/@shgysk8zer0/rollup-import)](https://www.npmjs.com/package/@shgysk8zer0/rollup-import)\n![node-current](https://img.shields.io/node/v/@shgysk8zer0/rollup-import)\n![npm bundle size gzipped](https://img.shields.io/bundlephobia/minzip/@shgysk8zer0/rollup-import)\n[![npm](https://img.shields.io/npm/dw/@shgysk8zer0/rollup-import?logo=npm)](https://www.npmjs.com/package/@shgysk8zer0/rollup-import)\n\n[![GitHub followers](https://img.shields.io/github/followers/shgysk8zer0.svg?style=social)](https://github.com/shgysk8zer0)\n![GitHub forks](https://img.shields.io/github/forks/shgysk8zer0/rollup-import.svg?style=social)\n![GitHub stars](https://img.shields.io/github/stars/shgysk8zer0/rollup-import.svg?style=social)\n[![Twitter Follow](https://img.shields.io/twitter/follow/shgysk8zer0.svg?style=social)](https://twitter.com/shgysk8zer0)\n\n[![Donate using Liberapay](https://img.shields.io/liberapay/receives/shgysk8zer0.svg?logo=liberapay)](https://liberapay.com/shgysk8zer0/donate \"Donate using Liberapay\")\n- - -\n\n- [Code of Conduct](./.github/CODE_OF_CONDUCT.md)\n- [Contributing](./.github/CONTRIBUTING.md)\n\u003c!-- - [Security Policy](./.github/SECURITY.md) --\u003e\n\n## Installation\n\n```bash\nnpm i @shgysk8zer0/rollup-import\n```\n\n## Supports\n- External [importmap](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script/type/importmap)\n  - JSON\n  - YAML\n- Object `{ imports, scope }` for importmap\n- Map `new Map([[specifier, value]])` for importmap\n- Importing modules from URL and paths and \"bare specifiers\"\n- Resolving `import.meta.url` and `import.meta.resolve('path.ext')`\n- [Import Attributes](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import/with) (`import mod from 'specifier' with { type }`)\n  - `'css'`\n  - `'json'`\n  - `'bytes'`\n  = `'text'`\n\n## Not yet supported\n- `import html from 'template.html' with { type: 'html' }` - No spec yet and will have issues with TrustedTypes\n- Parsing from `\u003cscript type=\"importmap\"\u003e` in an HTML file\n- Use of `scopes`\n\n## Example\n\n### `rollup.config.js`\n\n```js\nimport {\n  rollupImport, // Handles `import '@scope/package' resolving and fetching`\n  rollupImportMeta // Handles `import.meta.url` and `import.meta.resolve()`,\n} from '@shgysk8zer0/rollup-import';\n\nimport terser from '@rollup/plugin-terser';\n\n// To load environment variables from `.env`\nimport { config } from 'dotenv';\nconfig();\n\nexport default {\n  input: 'src/index.mjs',\n  plugins: [\n    rollupImport(['path/to/importmap.json']),\n    rollupImportMeta({\n      // MUST be a valid URL\n      baseURL: 'https://example.com', // Defaults to `process.env.URL` if set\n      // MUST be a `file:` URL\n      projectRoot: 'file:///home/user/Projects/my-project/', // Dfaults to `file:///${process.cwd()}/`\n    }),\n    terser(),\n  ],\n  output: {\n    file: 'dest/index.js',\n    format: 'iife'\n  }\n};\n```\n\n### `importmap.json`\n\n```json\n{\n  \"imports\": {\n    \"leaflet\": \"https://unpkg.com/leaflet@1.9.3/dist/leaflet-src.esm.js\",\n    \"firebase/\": \"https://www.gstatic.com/firebasejs/9.16.0/\",\n    \"@scope/package\": \"./node_modules/@scope/package/index.js\",\n    \"@shgysk8zer0/polyfills\": \"https://unpkg.com/@shgysk8zer0/polyfills@0.0.5/all.min.js\",\n    \"@shgysk8zer0/polyfills/\": \"https://unpkg.com/@shgysk8zer0@0.0.5/polyfills/\"\n  }\n}\n```\n\n### `index.js`\n\n```js\nimport '@scope/package';\nimport { initializeApp } from 'firebase/firebase-app.js';\nimport data from '@scope/package/data.json' with { type: 'json' }; // Results of `JSON.parser()`\nimport sheet from '@scope/lib/style.css' with { type: 'css' }; // A `CSSStyleSheet`\nimport bytes from '@scope/lib/icon.png' with { type: 'bytes' }; // A `Uint8Array`\nimport lorem from '@scope/lib/lorem-ipsum.txt' with { type: 'text' } // A string\nimport { name } from './consts.js';\n\nconst stylesheet = document.createElement('link');\nconst pre = document.createElement('pre');\nstylesheet.rel = 'stylesheet';\nstylesheet.href = import.meta.resolve('styles.css');\n\ndocument.head.append(stylesheet);\ndocument.adoptedStyleSheets = [sheet];\ndocument.title = data.title;\n\nconst img = document.createElement('img');\nimg.src = URL.createObjectURL(new Blob([bytes], { type: 'image/png' }));\npre.textContent = lorem;\ndocument.body.append(img, pre);\nimg.decode().then(() =\u003e URL.revokeObjectURL(img.src));\n```\n\n## Notes\n\nUsing `import`s only, you may use only `rollupImport` or `rollupImportMeta`\nvia `@shgysk8zer0/rollup-import/import` and `@shgysk8zer0/rollup-import/meta`\nrespectively. To use with `require()`, you MUST import either/both using\n`const {rollupImport, rollupImportMeta } = require('@shgysk8zer0/rollup-import')`.\n\nThis plugin works well if importing modules without bundling in the dev environment.\nIn order to do this, however, you **must** include a `\u003cscript type=\"importmap\"\u003e`\nin your HTML - `\u003cscript type=\"importmap\" src=\"...\"\u003e` will not work.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshgysk8zer0%2Frollup-import","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshgysk8zer0%2Frollup-import","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshgysk8zer0%2Frollup-import/lists"}