You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+37Lines changed: 37 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,6 +18,8 @@ _Note:_ It also works with `require()`, and you can alias a NPM module.
18
18
19
19
## Usage
20
20
21
+
If you're coming from babel-plugin-module-alias, please read this section: Updating from [babel-plugin-module-alias](#updating-from-babel-plugin-module-alias).
22
+
21
23
Install the plugin
22
24
23
25
```
@@ -41,6 +43,41 @@ Specify the plugin in your `.babelrc` with the custom root or alias. Here's an e
41
43
```
42
44
_Note:_ If you're using a custom extension (other than .js, .jsx, .es and .es6), you can add the `extensions` array in the config.
43
45
46
+
_Note 2:_ The "root" option also support a glob configuration, like `./src/**/components`.
47
+
48
+
49
+
### Updating from babel-plugin-module-alias
50
+
51
+
babel-plugin-module-resolver is a new version of the old babel-plugin-module-alias. Therefore, you also need to make a few modifications to your plugin configuration to make it work with this new plugin.
52
+
53
+
Updating is very easy, so for example if you had this configuration:
54
+
```
55
+
// This configuration is outdated, this is just an example
You ony have to update the plugin options to be like this:
68
+
```json
69
+
{
70
+
"plugins": [
71
+
["module-resolver", {
72
+
"root": ["./src"],
73
+
"alias": {
74
+
"underscore": "lodash"
75
+
}
76
+
}]
77
+
]
78
+
}
79
+
```
80
+
44
81
## ESLint plugin
45
82
46
83
If you're using ESLint, you should use the [eslint-plugin-import][eslint-plugin-import], and this [eslint-import-resolver-babel-module][eslint-import-resolver-babel-module] in order to remove falsy unresolved modules.
0 commit comments