babel-plugin-transform-import-maps
v0.1.1
Published
A plugin to transform ECMAScript module bare/url import specifiers at build-time
Downloads
7
Readme
babel-plugin-transform-import-maps
transform bare / url module specifiers in the import statement, export statement and dynamic import with importmap. see also rollup-plugin-import-maps
Contents:
Install
npm install --save-dev babel-plugin-transform-import-maps
Usage
Basic Usage
edit babel.config.json
{
"presets": [
["@babel/preset-env", {
"modules": false
}]
],
"plugins": [
["babel-plugin-transform-import-maps", {
"srcPath": "./index.importmap",
"transformingReport": "-"
}]
]
}
Plugin Options
srcPath
:string optionalfile path to importmap
srcText
:string optionalplain text of importmap
srcObject
:Object optionalparsed object of importmap
Note: One of
srcObject
,srcText
,srcPath
should be specified, if multiple of them specified, then precedence order is: srcObject, srcText, srcPath.baseDir
: string defaultprocess.cwd()
baseDir to calculate scope paths in order to match scopes defined in importmap
transformingReport
:string defaultundefined
set a file path to save transforming report as a Concatenated JSON file, will output to Console if value set to
"-"
exclude
:string|RegExp|Function defaultundefined
skip bare/url specifiers from resolving / transforming according to importmap.
e.g.
/\.(json|wasm|css)$/
,(source, importer)=> /\.(json|wasm|css)$/.test(source)
,.css,.wasm,.json
Related Efforts
- import-maps - Reference implementation playground for import maps proposal
Maintainers
License
Other licenses of dependencies
- import-maps: W3C Software and Document License and W3C CLA