Skip to content

Commit b27cb48

Browse files
committed
Add ES Modules build
1 parent 511fe67 commit b27cb48

File tree

5 files changed

+25
-16
lines changed

5 files changed

+25
-16
lines changed

.babelrc

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
plugins: [
2+
"plugins": [
33
["transform-es2015-template-literals", { "loose": true }],
44
"transform-es2015-literals",
55
"transform-es2015-function-name",
@@ -17,7 +17,13 @@
1717
"transform-es2015-parameters",
1818
["transform-es2015-destructuring", { "loose": true }],
1919
"transform-es2015-block-scoping",
20-
["transform-es2015-modules-commonjs", { "loose": true }],
2120
"transform-object-rest-spread"
22-
]
21+
],
22+
"env": {
23+
"commonjs": {
24+
"plugins": [
25+
["transform-es2015-modules-commonjs", { "loose": true }]
26+
]
27+
}
28+
}
2329
}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
node_modules
44
dist
55
lib
6+
es
67
coverage
78
_book

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ node_js:
33
- "4"
44
- "5"
55
script:
6-
- npm run check:lib
6+
- npm run check:src
77
- npm run build
88
- npm run check:examples
99
branches:

package.json

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,29 @@
33
"version": "3.2.1",
44
"description": "Predictable state container for JavaScript apps",
55
"main": "lib/index.js",
6-
"jsnext:main": "src/index.js",
6+
"jsnext:main": "es/index.js",
77
"files": [
88
"dist",
99
"lib",
10+
"es",
1011
"src"
1112
],
1213
"scripts": {
1314
"clean": "rimraf lib dist coverage",
1415
"lint": "eslint src test examples",
15-
"test": "mocha --compilers js:babel-register --recursive",
16+
"test": "cross-env BABEL_ENV=commonjs mocha --compilers js:babel-register --recursive",
1617
"test:watch": "npm test -- --watch",
17-
"test:cov": "babel-node $(npm bin)/isparta cover $(npm bin)/_mocha -- --recursive",
18-
"test:examples": "babel-node examples/testAll.js",
19-
"check:lib": "npm run lint && npm run test",
18+
"test:cov": "cross-env BABEL_ENV=commonjs babel-node $(npm bin)/isparta cover $(npm bin)/_mocha -- --recursive",
19+
"test:examples": "cross-env BABEL_ENV=commonjs babel-node examples/testAll.js",
20+
"check:src": "npm run lint && npm run test",
2021
"check:examples": "npm run build:examples && npm run test:examples",
21-
"build:lib": "babel src --out-dir lib",
22-
"build:umd": "cross-env NODE_ENV=development webpack src/index.js dist/redux.js",
23-
"build:umd:min": "cross-env NODE_ENV=production webpack src/index.js dist/redux.min.js",
24-
"build:examples": "babel-node examples/buildAll.js",
25-
"build": "npm run build:lib && npm run build:umd && npm run build:umd:min && node ./prepublish",
26-
"prepublish": "npm run clean && npm run check:lib && npm run build",
22+
"build:commonjs": "cross-env BABEL_ENV=commonjs babel src --out-dir lib",
23+
"build:es": "cross-env BABEL_ENV=es babel src --out-dir es",
24+
"build:umd": "cross-env BABEL_ENV=commonjs NODE_ENV=development webpack src/index.js dist/redux.js",
25+
"build:umd:min": "cross-env BABEL_ENV=commonjs NODE_ENV=production webpack src/index.js dist/redux.min.js",
26+
"build:examples": "cross-env BABEL_ENV=commonjs babel-node examples/buildAll.js",
27+
"build": "npm run build:commonjs && npm run build:es && npm run build:umd && npm run build:umd:min && node ./prepublish",
28+
"prepublish": "npm run clean && npm run check:src && npm run build",
2729
"docs:clean": "rimraf _book",
2830
"docs:prepare": "gitbook install",
2931
"docs:build": "npm run docs:prepare && gitbook build -g rackt/redux",

prepublish.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ var glob = require('glob')
22
var fs = require('fs')
33
var es3ify = require('es3ify')
44

5-
glob('./@(lib|dist)/**/*.js', function (err, files) {
5+
glob('./@(lib|dist|es)/**/*.js', function (err, files) {
66
if (err) {
77
throw err
88
}

0 commit comments

Comments
 (0)