Skip to content

Commit

Permalink
docs: tweaks [ci skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
59naga committed Sep 28, 2018
1 parent d0001d5 commit e8e5be0
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions README.md
Expand Up @@ -71,9 +71,7 @@ Write the name to [babelrc](https://babeljs.io/docs/usage/babelrc/). It works wi
```json
{
"presets": ["@babel/env"],
"plugins": [
"add-module-exports"
]
"plugins": ["add-module-exports"]
}
```

Expand All @@ -84,10 +82,8 @@ this plugin makes changes only when exists `exports.default` (in other words, us

```json
{
"presets": [["@babel/env", {"modules": false}]],
"plugins": [
"add-module-exports"
]
"presets": [["@babel/env", { "modules": false }]],
"plugins": ["add-module-exports"]
}
```

Expand All @@ -102,13 +98,13 @@ Doesn't support `amd`, `systemjs` modules(don't use. there are no plans to suppo

### with Webpack

Likewise, webpack doesn't perform commonjs transformation for [codesplitting](https://webpack.js.org/guides/code-splitting/). Need to set commonjs conversion.
Likewise, webpack doesn't perform commonjs transformation for [codesplitting](https://webpack.js.org/guides/code-splitting/). Need to set commonjs conversion.

```js
module.exports = {
presets: [["@babel/env", { modules: "commonjs" }]],
plugins: ["add-module-exports"]
};
```json
{
"presets": [["@babel/env", { "modules": "commonjs" }]],
"plugins": ["add-module-exports"]
}
```

Options
Expand All @@ -122,13 +118,18 @@ If you're exporting an object and wish to maintain compatibility with code using
{
"presets": ["env"],
"plugins": [
["add-module-exports", {
"addDefaultProperty": true
}]
[
"add-module-exports",
{
"addDefaultProperty": true
}
]
]
}
```

This will cause a second line of code to be added which aliases the `default` name to the exported object like so:

```js
module.exports = exports['default'];
module.exports.default = exports['default']
Expand Down

0 comments on commit e8e5be0

Please sign in to comment.