Gathering detailed insights and metrics for babel-plugin-module-resolver
Gathering detailed insights and metrics for babel-plugin-module-resolver
Gathering detailed insights and metrics for babel-plugin-module-resolver
Gathering detailed insights and metrics for babel-plugin-module-resolver
eslint-import-resolver-babel-module
babel-plugin-module-resolver resolver for eslint-plugin-import
babel-plugin-tsconfig-paths-module-resolver
A babel plugin that combines babel-plugin-module-resolver and tsconfig-paths to resolve tsconfig paths
@stavalfi/babel-plugin-module-resolver-loader
webpack loader for babel-plugin-module-resolver
babel-plugin-module-resolver-tsconfig
"Write the aliases only in tsconfig. It should be that simple.". A helper module that provide easy configuration of babel-plugin-module-resolver plugin for typescript projects. To avoid repeating writing the aliases in both tsconfig and .babelrc.js. And t
Custom module resolver plugin for Babel
npm install babel-plugin-module-resolver
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
3,461 Stars
229 Commits
205 Forks
17 Watching
4 Branches
48 Contributors
Updated on 19 Nov 2024
Minified
Minified + Gzipped
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-12.8%
478,327
Compared to previous day
Last week
-3.4%
2,513,911
Compared to previous week
Last month
11.3%
10,738,153
Compared to previous month
Last year
6.9%
124,821,916
Compared to previous year
5
A Babel plugin to add a new resolver for your modules when compiling your code using Babel. This plugin allows you to add new "root" directories that contain your modules. It also allows you to setup a custom alias for directories, specific files, or even other npm modules.
This plugin can simplify the require/import paths in your project. For example, instead of using complex relative paths like ../../../../utils/my-utils
, you can write utils/my-utils
. It will allow you to work faster since you won't need to calculate how many levels of directory you have to go up before accessing the file.
1// Use this: 2import MyUtilFn from 'utils/MyUtilFn'; 3// Instead of that: 4import MyUtilFn from '../../../../utils/MyUtilFn'; 5 6// And it also work with require calls 7// Use this: 8const MyUtilFn = require('utils/MyUtilFn'); 9// Instead of that: 10const MyUtilFn = require('../../../../utils/MyUtilFn');
Install the plugin
npm install --save-dev babel-plugin-module-resolver
or
yarn add --dev babel-plugin-module-resolver
Specify the plugin in your .babelrc
with the custom root or alias. Here's an example:
1{ 2 "plugins": [ 3 ["module-resolver", { 4 "root": ["./src"], 5 "alias": { 6 "test": "./test", 7 "underscore": "lodash" 8 } 9 }] 10 ] 11}
.babelrc.js version
Specify the plugin in your .babelrc.js
file with the custom root or alias. Here's an example:
const plugins = [
[
require.resolve('babel-plugin-module-resolver'),
{
root: ["./src/"],
alias: {
"test": "./test"
}
}
]
];
Good example: // https://gist.github.com/nodkz/41e189ff22325a27fe6a5ca81df2cb91
babel-plugin-module-resolver can be configured and controlled easily, check the documentation for more details
Are you a plugin author (e.g. IDE integration)? We have documented the exposed functions for use in your plugins!
If you're using ESLint, you should use eslint-plugin-import, and eslint-import-resolver-babel-module to remove falsy unresolved modules. If you want to have warnings when aliased modules are being imported by their relative paths, you can use eslint-plugin-module-resolver.
babel-plugin-module-resolver
option.jsconfig.json
(tsconfig.json
for TypeScript), e.g.:1{ 2 "compilerOptions": { 3 "baseUrl": ".", 4 "paths": { 5 "*": ["src/*"], 6 "test/*": ["test/*"], 7 "underscore": ["lodash"] 8 } 9 } 10}
../../../utils/MyUtilFn
you can mark
../../../utils
as "resources root". This has the problem that your alias also has to be named utils
. The second option is to add
a webpack.config.js
to your project and use it under File->Settings->Languages&Frameworks->JavaScript->Webpack. This will trick webstorm
into resolving the paths and you can use any alias you want e.g.:1var path = require('path'); 2 3module.exports = { 4 resolve: { 5 extensions: ['.js', '.json', '.vue'], 6 alias: { 7 utils: path.resolve(__dirname, '../../../utils/MyUtilFn'), 8 }, 9 }, 10};
MIT, see LICENSE.md for details.
Are you also using it? Send a PR!
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 11/26 approved changesets -- score normalized to 4
Reason
dependency not pinned by hash detected -- score normalized to 4
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
16 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More