Skip to content

Commit 57e6b64

Browse files
goto-bus-stopyangmillstheory
authored andcommitted
Add ES-modules build (#175)
1 parent f623022 commit 57e6b64

File tree

5 files changed

+18
-4
lines changed

5 files changed

+18
-4
lines changed

.babelrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"presets": [
3-
"es2015",
3+
"./build/preset-es2015",
44
"stage-0"
55
]
66
}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
node_modules
22
coverage
33
*.log
4+
es
45
lib
56
dist
67
.idea

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
npm install --save redux-actions
1313
```
1414

15+
The [npm](https://www.npmjs.com) package provides a [CommonJS](http://webpack.github.io/docs/commonjs.html) build for use in Node.js, and with bundlers like [Webpack](http://webpack.github.io/) and [Browserify](http://browserify.org/). It also includes an [ES modules](http://jsmodules.io/) build that works well with [Rollup](http://rollupjs.org/) and [Webpack2](https://webpack.js.org)'s tree-shaking.
16+
1517
If you don’t use [npm](https://www.npmjs.com), you may grab the latest [UMD](https://unpkg.com/redux-actions@latest/dist) build from [unpkg](https://unpkg.com) (either a [development](https://unpkg.com/redux-actions@latest/dist/redux-actions.js) or a [production](https://unpkg.com/redux-actions@latest/dist/redux-actions.min.js) build). The UMD build exports a global called `window.ReduxActions` if you add it to your page via a `<script>` tag. We *don’t* recommend UMD builds for any serious application, as most of the libraries complementary to Redux are only available on [npm](https://www.npmjs.com/search?q=redux).
1618

1719
## Usage

build/preset-es2015.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const esOptions = process.env.BABEL_ENV === 'es' ? { modules: false } : {};
2+
3+
module.exports = {
4+
presets: [
5+
['es2015', esOptions]
6+
]
7+
};

package.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,24 @@
33
"version": "1.1.0",
44
"description": "Flux Standard Action utlities for Redux",
55
"main": "lib/index.js",
6+
"module": "es/index.js",
7+
"jsnext:main": "es/index.js",
68
"scripts": {
9+
"build:es": "cross-env BABEL_ENV=es babel src --out-dir es --ignore *-test.js",
710
"build:commonjs": "babel src --out-dir lib --ignore *-test.js",
811
"build:umd": "cross-env NODE_ENV=development webpack",
912
"build:umd:min": "cross-env NODE_ENV=production webpack",
10-
"build": "npm run clean && npm run build:commonjs && npm run build:umd && npm run build:umd:min",
11-
"clean": "rimraf lib",
12-
"lint": "esw src webpack.config --color",
13+
"build": "npm run clean && npm run build:es && npm run build:commonjs && npm run build:umd && npm run build:umd:min",
14+
"clean": "rimraf lib es",
15+
"lint": "esw build src webpack.config --color",
1316
"lint:fix": "npm run lint -- --fix",
1417
"lint:watch": "npm run lint -- --watch",
1518
"prepublish": "npm run lint && npm run test && npm run build",
1619
"test": "mocha --compilers js:babel-register src/**/*-test.js",
1720
"test:watch": "npm run test -- --watch src/**/*-test.js"
1821
},
1922
"files": [
23+
"es",
2024
"lib",
2125
"dist"
2226
],

0 commit comments

Comments
 (0)