0.1.1 • Published 2 years ago

babel-plugin-transform-import-maps v0.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

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 optional

    file path to importmap

  • srcText:string optional

    plain text of importmap

  • srcObject:Object optional

    parsed 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 default process.cwd()

    baseDir to calculate scope paths in order to match scopes defined in importmap

  • transformingReport:string default undefined

    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 default undefined

    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

@fuweichin

License

MIT

Other licenses of dependencies