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
true
.
default 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
['.js']
.
default 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
['mod', 'lib']
.
default 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.