Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
babel-plugin-module-extension-resolver
Advanced tools
Babel plugin that resolves and maps module extensions.
Babel plugin that resolves and maps module extensions.
Inspired by babel-plugin-extension-resolver.
Directory structure:
root
├ dir
│ ├ index.js
│ └ lib.js
├ main.js
└ settings.json
Input (main.js
):
require("./dir/lib");
require("./dir/lib.js"); // file exists
require("./dir"); // directory has "index.js"
require("./settings"); // ".json" extension
require("./no-such-file"); // file NOT exists
require("dir"); // not begins with "."
Output:
require("./dir/lib.js");
require("./dir/lib.js");
require("./dir/index.js");
require("./settings.json");
require("./no-such-file");
require("dir");
.mjs
extension)Directory structure:
root
├ dir
│ ├ index.mjs
│ └ lib.mjs
└ main.mjs
Input (main.mjs
):
import "./dir/lib";
import "./dir";
Output:
import "./dir/lib.mjs";
import "./dir/index.mjs";
Directory structure:
root
├ dir
│ ├ index.ts
│ └ lib.ts
└ main.ts
Input (main.ts
):
import "./dir/lib";
import "./dir";
Output:
import "./dir/lib.js";
import "./dir/index.js";
NOTE: .ts
is replaced with .js
. This behavior can be customized by options.
For complete project, see below examples.
@babel/preset-env
@babel/preset-typescript
tsc
and Babelnpm i -D babel-plugin-module-extension-resolver
.babelrc
{
"plugins": ["module-extension-resolver"]
}
With options:
{
"plugins": [
["module-extension-resolver", {
"extensions": [".js", ".cjs", ".mjs", ".es", ".es6", ".ts", ".node", ".json"],
"map": {
".ts": ".js",
".es": ".js",
".es6": ".js",
".node": ".js"
}
}]
]
}
extensions
extensions to resolve
defaults:
[
".js",
".cjs",
".mjs",
".es",
".es6",
".ts",
".node",
".json"
]
map
extension mapper
defaults:
{
".ts": ".js",
".es": ".js",
".es6": ".js",
".node": ".js"
}
See CHANGELOG.md.
[0.2.0] - 2020-01-04
export from
syntax.cjs
extensionFAQs
Babel plugin that resolves and maps module extensions.
The npm package babel-plugin-module-extension-resolver receives a total of 1,623 weekly downloads. As such, babel-plugin-module-extension-resolver popularity was classified as popular.
We found that babel-plugin-module-extension-resolver demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.