@snowpack/babel-plugin-package-import
v1.1.6
Published
Babel plugin to rewrite package imports from their package name to their resolved `web_modules` URL. Uses the `import-map.json` file contained in each `web_modules/` directory to map each package.
Downloads
1,314
Readme
@snowpack/babel-plugin-package-import
Babel plugin to rewrite package imports from their package name to their resolved web_modules
URL. Uses the import-map.json
file contained in each web_modules/
directory to map each package.
npm install --save-dev @snowpack/babel-plugin-package-import
// babel.config.json / .babelrc
"plugins": [["@snowpack/babel-plugin-package-import", { /* options */ }]]
Plugin Options
Note: All config options are optional.
webModulesUrl
: The hosted URL path reference for web_modules imports. Can be:- An absolute path ("/web_modules"). This is the default.
- An absolute URL ("https://foobar.com/web_modules/")
- A relative path prefix ("./web_modules", "../web_modules"). NOTE: Relative paths are relative from the current working directory / Babel's "root".
webModulesDir
: The web_modules installed location on disk. Can be an absolute path, or relative to the current working directory.- Defaults to "${cwd}/web_modules".
importMap
: The name/location of the "import-map.json" file generated by Snowpack.- Defaults to "${webModulesDir}/import-map.json".
moduleResolution
: Control how the plugin rewrites relative/local imports. Defaults to "none"."none"
: Leave relative imports untouched."node"
: Rewrite all relative paths to use node's built-in resolution, resolving things like missing file extensions and directory imports. This is useful to assist migrating an older, bundled project to Snowpack.
ignore
: Array of import specifiers to ignore and leave untouched / bare.