Skip to content

Commit

Permalink
Merge pull request #82 from weslleyaraujo/master
Browse files Browse the repository at this point in the history
feat(build): Adding UMD support
  • Loading branch information
omnidan committed Apr 15, 2016
2 parents 527caf3 + e5e745a commit 3568aa8
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ node_modules
.DS_Store
lib
coverage
dist
es
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,28 @@ or plan on using 0.6, check out [the `0.6` branch](https://github.com/omnidan/re

---

## Note on 1.0.0-beta7

If you use Redux Undo in CommonJS environment, **don’t forget to add `.default` to your import**.

```diff
- var ReduxUndo = require('redux-undo')
+ var ReduxUndo = require('redux-undo').default
```

If your environment support es modules just go by:

```js
import ReduxUndo from 'redux-undo';
```

We are also supporting UMD build:

```js
var ReduxUndo = window.ReduxUndo.default;
```

**once again `.default` is required.**

## Installation

Expand Down Expand Up @@ -286,7 +308,6 @@ Have a read of the [Implementing Undo History recipe](http://redux.js.org/docs/r

If you have a question or just want to discuss something with other redux-undo users/maintainers, [chat with the community on gitter.im/omnidan/redux-undo](https://gitter.im/omnidan/redux-undo)


## License

MIT, see `LICENSE.md` for more information.
21 changes: 14 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
{
"name": "redux-undo",
"version": "1.0.0-beta6",
"version": "1.0.0-beta7",
"description": "simple undo/redo functionality for redux state containers",
"main": "lib/index.js",
"scripts": {
"clean": "./node_modules/.bin/rimraf lib",
"compile": "./node_modules/.bin/babel src --out-dir lib",
"lint": "./node_modules/.bin/eslint src test",
"build": "npm run build:commonjs && npm run build:umd && npm run build:umd:min && npm run build:es",
"build:commonjs": "cross-env BABEL_ENV=commonjs babel src --out-dir lib",
"build:es": "cross-env BABEL_ENV=es babel src --out-dir es",
"build:umd": "cross-env BABEL_ENV=commonjs NODE_ENV=development webpack",
"build:umd:min": "cross-env BABEL_ENV=commonjs NODE_ENV=production webpack",
"clean": "./node_modules/.bin/rimraf lib dist es",
"lint": "./node_modules/.bin/eslint webpack.config.babel.js src test",
"prepublish": "npm run lint && npm run test && npm run clean && npm run build",
"test": "NODE_ENV=test ./node_modules/.bin/mocha --compilers js:babel-core/register",
"test:watch": "npm run test -- --watch",
"test:bail": "npm run test:watch -- --bail",
"test:cov": "./node_modules/.bin/babel-node ./node_modules/.bin/isparta cover ./node_modules/.bin/_mocha",
"prepublish": "npm run lint && npm run test && npm run clean && npm run compile"
"test:watch": "npm run test -- --watch"
},
"repository": {
"type": "git",
Expand All @@ -34,8 +38,10 @@
"babel-cli": "^6.5.1",
"babel-core": "^6.5.2",
"babel-eslint": "^5.0.0",
"babel-loader": "^6.2.4",
"babel-plugin-transform-object-rest-spread": "^6.5.0",
"babel-preset-es2015": "^6.5.0",
"cross-env": "^1.0.7",
"chai": "^3.5.0",
"eslint": "2.2.0",
"eslint-config-standard": "^5.1.0",
Expand All @@ -44,7 +50,8 @@
"expect": "^1.14.0",
"isparta": "^4.0.0",
"mocha": "^2.4.5",
"rimraf": "^2.5.2"
"rimraf": "^2.5.2",
"webpack": "^1.12.14"
},
"dependencies": {
"redux": "^3.3.1"
Expand Down
46 changes: 46 additions & 0 deletions webpack.config.babel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import webpack from 'webpack'
import path from 'path'

const { NODE_ENV } = process.env

const plugins = [
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(NODE_ENV)
})
]

const filename = `redux-undo${NODE_ENV === 'production' ? '.min' : ''}.js`

NODE_ENV === 'production' && plugins.push(
new webpack.optimize.UglifyJsPlugin({
compressor: {
pure_getters: true,
unsafe: true,
unsafe_comps: true,
screw_ie8: true,
warnings: false
}
})
)

export default {
module: {
loaders: [
{ test: /\.js$/, loaders: ['babel-loader'], exclude: /node_modules/ }
]
},

entry: [
'./src/index'
],

output: {
path: path.join(__dirname, 'dist'),
filename,
library: 'ReduxUndo',
libraryTarget: 'umd'
},

plugins
}

0 comments on commit 3568aa8

Please sign in to comment.