https://github.com/shgysk8zer0/importmap
Front-End dependencies based on `<script type="importmap">`
https://github.com/shgysk8zer0/importmap
importmap node npm rollup
Last synced: 13 days ago
JSON representation
Front-End dependencies based on `<script type="importmap">`
- Host: GitHub
- URL: https://github.com/shgysk8zer0/importmap
- Owner: shgysk8zer0
- License: mit
- Created: 2023-05-31T02:18:19.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2026-06-04T02:50:52.000Z (21 days ago)
- Last Synced: 2026-06-04T04:23:20.121Z (20 days ago)
- Topics: importmap, node, npm, rollup
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/@shgysk8zer0/importmap
- Size: 1.17 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
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
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# @shgysk8zer0/importmap
Front-End dependencies based on [``](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script/type/importmap)
Intended for use with [`rollup`](https://rollupjs.org/) and [`@shgysk8zer0/rollup-import`](https://www.npmjs.com/package/@shgysk8zer0/rollup-import).
- - -
[](https://github.com/shgysk8zer0/importmap/actions/workflows/codeql-analysis.yml)


[](https://github.com/shgysk8zer0/importmap/blob/master/LICENSE)
[](https://github.com/shgysk8zer0/importmap/commits/master)
[](https://github.com/shgysk8zer0/importmap/releases)
[](https://github.com/sponsors/shgysk8zer0)
[](https://www.npmjs.com/package/@shgysk8zer0/importmap)


[](https://www.npmjs.com/package/@shgysk8zer0/importmap)
[](https://github.com/shgysk8zer0)


[](https://twitter.com/shgysk8zer0)
[](https://liberapay.com/shgysk8zer0/donate "Donate using Liberapay")
- - -
- [Code of Conduct](./.github/CODE_OF_CONDUCT.md)
- [Contributing](./.github/CONTRIBUTING.md)
<!-- - [Security Policy](./.github/SECURITY.md) -->
## Installation
```bash
npm i @shgysk8zer0/importmap
```
## Example
```js
// rollup.config.js
import { rollupImport } from '@shgysk8zer0/rollup-import';
import { imports } from '@shgysk8zer0/importmap';
export default {
input: 'index.js',
output: {
file: 'index.min.js',
format: 'iife',
sourcemap: true,
},
plugins: [rollupImport({ imports })],
};
```
## For `<script type="importmap">`
The module exports `getImportMapScript()`, which can be used to generate the
required importmap `<script>`:
```js
import { getImportMapScript } from '@shgysk8zer0/importmap';
getImportMapScript();
```
Which results in:
```html
<script type="importmap" integrity="sha384-...">{"imports": {}, "scope": {}}
```
## CLI
### `importmap-utils`
Create / update local importmap JSON or YAML files.
```
Usage: importmap-utils [options]
CLI utility for updating importmap files
Options:
-V, --version output the version number
-i, --input [input] local JSON or YAML importmap file
-e, --encoding [encoding] encoding (default: "utf8")
-f, --format [format] output format
-o, --output output file
-h, --help display help for command
```
### `importmap-html`
Updates the `` in an HTML file
```
Usage: importmap-html [options] <html-file>
CLI utility for updating `<script type="importmap">` in HTML files
Options:
-V, --version output the version number
-a, --algo [algo] Hashing algorigthm to use for `integrity` (default: "SHA-384")
-s, --spaces [spaces] Spaces to indent with
-i, --importmap [importmap] Source importmap.json file.
-h, --help display help for command
```
### CLI Example
```bash
importmap-utils -o importmap.json
# Or...
importmap-utils -i importmap.json -o importmap.yml -f yaml
importmap-html index.html
importmap index.html -i imports.json -a sha-512
```