esm-build-2
v1.1.12
Published
Build ESM import maps with hash versioning
Downloads
26
Readme
esm-imports-builder
Creates a version hashed import map of all ESM modules in source folder. ESM import map
Install
- npm install esm-build-2 -g
Create a buildconfig.json file. Example:
Minimal config:
{
"sourcedir": "./src",
"entryhtml": "./src/index.html",
"modifyEntryHtml": true
}
All config options:
{
"sourcedir": "./src",
"outputFile": "./src/importmap.json",
"entryhtml": "./src/index.html",
"modifyEntryHtml": true,
"generateOutputFile": true,
"excludes": [
"*/ignoredfolder/**"
],
"addImports": {
"added": "./lib/other.js"
},
"hashAddedImports": false,
"addScopes": {
"http://test": {
"added": "http://test/some-path/version1/added.js"
}
}
}
Configuration specification
- "sourcedir": the path were the source of the ESM modules can be found
- "outputFile": the JSON file which should contain the import maps
- "entryhtml": the HTML file which is the entry point to the application and which should contain the import maps (will replace existing import maps if placed in html head)
- "modifyEntryHtml": true if HTML file should be modified
- "generateOutputFile": true if the JSON import maps file should be created
- "excludes": array of excluded folders/files
- "addImports": additional fixed imports not found in source directory
- "hashAddedImports": read and set hashed version for additional imports
- "addScopes": additional/optional fixed scopes for import maps
If "excludes" is included, i should contain an array of glob patterns to exclude files/folders.
Execute import map build with:
> esm-build
Optional arguments:
-c [path to config file] (supply path to config file)
-w (watch for changes and build on demand)
With argument(s):
> esm-build -c buildconfig.json
> esm-build -w