Skip to content

shgysk8zer0/importmap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

736 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

@shgysk8zer0/importmap

Front-End dependencies based on <script type="importmap">

Intended for use with rollup and @shgysk8zer0/rollup-import.


CodeQL Node CI Lint Code Base

GitHub license GitHub last commit GitHub release GitHub Sponsors

npm node-current npm bundle size gzipped npm

GitHub followers GitHub forks GitHub stars Twitter Follow

Donate using Liberapay


Installation

npm i @shgysk8zer0/importmap

Example

// 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>:

import { getImportMapScript } from '@shgysk8zer0/importmap';

getImportMapScript();

Which results in:

<script type="importmap" integrity="sha384-...">{"imports": {}, "scope": {}}</script>

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>      output file
  -h, --help                 display help for command

importmap-html

Updates the <script type="importmap"> 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

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

About

Front-End dependencies based on `<script type="importmap">`

Topics

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Sponsor this project

  •  

Contributors