Skip to content

Commit

Permalink
Export default property in CommonJS and global object
Browse files Browse the repository at this point in the history
In Babel 5, the ES6 default property was exported as both default
property under the CommonJS export (module.exports) and global object
(in UMD wrapper, on browser). With babel 6 this behaviour was changed
(babel/babel#2212) and now using library
requires e.g.

require("react-modal").default instead of just require("react-modal")
ReactModal.default instead of ReactModal

This babel plugin restores the old behaviour.
  • Loading branch information
Deraen authored and diasbruno committed Sep 6, 2017
1 parent ba526cf commit 54c59c5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"presets": ["es2015", "stage-2", "react"]
"presets": ["es2015", "stage-2", "react"],
"plugins": [
"add-module-exports"
]
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"babel-core": "^6.25.0",
"babel-eslint": "^7.1.1",
"babel-loader": "^6.2.4",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-2": "^6.24.1",
Expand Down

0 comments on commit 54c59c5

Please sign in to comment.