Skip to content

Add ES-modules build #175

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"presets": [
"es2015",
"./build/preset-es2015",
"stage-0"
]
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
node_modules
coverage
*.log
es
lib
dist
.idea
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
npm install --save redux-actions
```

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.

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).

## Usage
Expand Down
7 changes: 7 additions & 0 deletions build/preset-es2015.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const esOptions = process.env.BABEL_ENV === 'es' ? { modules: false } : {};

module.exports = {
presets: [
['es2015', esOptions]
]
};
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,24 @@
"version": "1.1.0",
"description": "Flux Standard Action utlities for Redux",
"main": "lib/index.js",
"module": "es/index.js",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this module key for? Couldn't find anything about it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

module serves about the same purpose as jsnext:main and is used by webpack2 and Rollup. I went by this Rollup wiki page which says

If in doubt, use both!

"jsnext:main": "es/index.js",
"scripts": {
"build:es": "cross-env BABEL_ENV=es babel src --out-dir es --ignore *-test.js",
"build:commonjs": "babel src --out-dir lib --ignore *-test.js",
"build:umd": "cross-env NODE_ENV=development webpack",
"build:umd:min": "cross-env NODE_ENV=production webpack",
"build": "npm run clean && npm run build:commonjs && npm run build:umd && npm run build:umd:min",
"clean": "rimraf lib",
"lint": "esw src webpack.config --color",
"build": "npm run clean && npm run build:es && npm run build:commonjs && npm run build:umd && npm run build:umd:min",
"clean": "rimraf lib es",
"lint": "esw build src webpack.config --color",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we linting build/? Is there even a build/ directory?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's for the new build/preset-es2015.js file.

"lint:fix": "npm run lint -- --fix",
"lint:watch": "npm run lint -- --watch",
"prepublish": "npm run lint && npm run test && npm run build",
"test": "mocha --compilers js:babel-register src/**/*-test.js",
"test:watch": "npm run test -- --watch src/**/*-test.js"
},
"files": [
"es",
"lib",
"dist"
],
Expand Down