Skip to content

Commit

Permalink
docs: Add a note explaing how to update from module-alias to module-r…
Browse files Browse the repository at this point in the history
…esolver

Fixes #76
  • Loading branch information
Tommy Leunen committed Aug 27, 2016
1 parent a4cff68 commit b016b6f
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ _Note:_ It also works with `require()`, and you can alias a NPM module.

## Usage

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).

Install the plugin

```
Expand All @@ -41,6 +43,41 @@ Specify the plugin in your `.babelrc` with the custom root or alias. Here's an e
```
_Note:_ If you're using a custom extension (other than .js, .jsx, .es and .es6), you can add the `extensions` array in the config.

_Note 2:_ The "root" option also support a glob configuration, like `./src/**/components`.


### Updating from babel-plugin-module-alias

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.

Updating is very easy, so for example if you had this configuration:
```
// This configuration is outdated, this is just an example
{
"plugins": [
["module-alias", [
{ "src": "./src/utils", "expose": "utils" },
{ "src": "./src/components", "expose": "components" },
{ "src": "./src/actions", "expose": "actions" },
{ "src": "npm:lodash", "expose": "underscore" }
]]
]
}
```
You ony have to update the plugin options to be like this:
```json
{
"plugins": [
["module-resolver", {
"root": ["./src"],
"alias": {
"underscore": "lodash"
}
}]
]
}
```

## ESLint plugin

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.
Expand Down

0 comments on commit b016b6f

Please sign in to comment.