From 54c59c5cf4c7fe8d82b79a88cd85418b2ae9a494 Mon Sep 17 00:00:00 2001 From: Juho Teperi Date: Wed, 6 Sep 2017 16:50:57 +0300 Subject: [PATCH] Export default property in CommonJS and global object 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 (https://github.com/babel/babel/issues/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. --- .babelrc | 5 ++++- package.json | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.babelrc b/.babelrc index e68d2fea..851afd50 100644 --- a/.babelrc +++ b/.babelrc @@ -1,3 +1,6 @@ { - "presets": ["es2015", "stage-2", "react"] + "presets": ["es2015", "stage-2", "react"], + "plugins": [ + "add-module-exports" + ] } diff --git a/package.json b/package.json index 9ea0286f..fc8d0917 100644 --- a/package.json +++ b/package.json @@ -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",