Skip to content

Commit

Permalink
Support ESM modules
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Dijou committed Mar 21, 2020
1 parent 7048d1d commit ae6cff2
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
4 changes: 0 additions & 4 deletions .babelrc

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
node_modules
lib
esm
coverage
dist
.nyc_output
18 changes: 18 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
var modules;
var moduleTarget = process.env['MODULE_TARGET'];

if (moduleTarget === 'commonjs') {
modules = 'commonjs';
} else if (moduleTarget === 'esm') {
modules = false;
} else {
throw new Error('Wrong value for MODULE_TARGET: ' + moduleTarget);
}

module.exports = {
presets: [['@babel/preset-env', { modules: modules }]],
plugins: [
'@babel/plugin-proposal-object-rest-spread',
'@babel/plugin-transform-object-assign'
]
};
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"batch"
],
"main": "lib/index.js",
"module": "esm/index.js",
"types": "./types.d.ts",
"typings": "./types.d.ts",
"homepage": "https://github.com/pauldijou/redux-act",
Expand All @@ -27,7 +28,9 @@
},
"scripts": {
"clean": "rm -rf lib",
"build": "babel src --out-dir lib",
"build:commonjs": "MODULE_TARGET=commonjs babel src --out-dir lib",
"build:esm": "MODULE_TARGET=esm babel src --out-dir esm",
"build": "yarn build:commonjs && yarn build:esm",

This comment has been minimized.

Copy link
@AndyOGo

AndyOGo Mar 21, 2020

👍

"browserify": "mkdir -p dist && browserify -s ReduxAct lib/index.js > dist/redux-act.js",
"minify": "terser dist/redux-act.js -o dist/redux-act.min.js",
"prepublish": "yarn clean && yarn build && yarn browserify && yarn minify",
Expand Down

0 comments on commit ae6cff2

Please sign in to comment.