babel-plugin-transform-resolve-wildcard-import
Transforms wildcard style imports:
; ; x; x; console;
into member style imports:
; ; ; ; console;
(well, that would be ideal, but actually it looks more like the following, which is a bit simpler to implement:)
; ; var x = a: _a b: _b; x; x; console;
This is useful in some situations to get webpack and similar tools to tree-shake better.
Note: This plugin only works when the wildcard import (x
in the
example) is only ever used in a property access. If you use x
directly, then we leave the wildcard import in place.
Options
By default this will apply to all wildcard imports, for example with a .babelrc like:
{
"plugins": ["babel-plugin-transform-resolve-wildcard-import"]
}
If you only want it to apply this to certain import paths you can
restrict the transforms with an array of regular expressions passed as
only
:
{
"plugins": [
["babel-plugin-transform-resolve-wildcard-import", {only: [
"^lodash$",
"^\.\.?\/UI(\/(index(\.js)?)?)?$"
]}]
]
}