babel-plugin-import-src-remap

1.1.0 • Public • Published

import-src-remap (for babel)

Babel plugin to remaps ES6 import directive sources which point to src paths to relevant built (e.g. lib or mod) paths, useful for ensuring correct navigation within an IDE and correct mapping to transformed output at runtime/build time.

Maps local relative path imports (for instance used in test folder):
../src to ../lib or ./src to ./lib

Maps library imports, if suffixed with /src:
lib-name/src to lib-name

Maps library sub sub-directory imports:
lib-name/src/sub-component to lib-name/lib/sub-component

Usage:

Add "import-src-remap" to your babel plugins configuration.

Options

Options can be specified via the babel plugin options mechanism.

resolve

default true.

When true ensures the import is resolvable to the provided dirs and extensions, attempting to resolve the given parameters in the given order (according to node resolve algorithm), mapping the import to the first value to correctly resolve.

If false the first given dir value will be used, extensions are ignored.

extensions

default ['.js'].

Array of extensions to attempt to resolve if resolve is true. If the source import has an extension this will be the first attempted before the values of the given array.

dirs

default ['mod', 'lib'].

Array of dirs to attempt to resolve if resolve is true. If the import directive has an extension this value will be attempted before the values of the given array.

Package Sidebar

Install

npm i babel-plugin-import-src-remap

Weekly Downloads

1

Version

1.1.0

License

MIT

Last publish

Collaborators

  • jsui