Options for resolving submodules in installed modules (import foo from 'bar/foo'
).
Must be set to an object to be enabled. That object may contain the following options.
A list of extensions to resolve when importing a module's submodules.
[".js", ".json"]
Set to true
to ignore any submodule modules that cannot be resolved.
Set to true
to ignore any modules that have an exports
entry (very important).
.babelrc
{
"presets": [
[
"@babel/preset-env",
{
"modules": false,
"targets": {
"node": "current"
}
}
]
],
"plugins": [
[
"esm-resolver",
{
"submodule": {
"extensions": [".mjs", ".js"],
"ignoreExports": true
}
}
]
]
}
src/main.js
import {foo} from 'bar/foo';
output:
import {foo} from 'bar/foo.mjs';