From 746c4506ba705e286cf15807096b76958282b5b8 Mon Sep 17 00:00:00 2001 From: Denis Bardadym Date: Tue, 27 Sep 2016 19:46:13 +0300 Subject: [PATCH] Add es2015 modules export from redux project (#501) * Remove Style section Obviously that didn't happen... * Add es2015 modules export from redux project --- .babelrc | 11 ++++++++++- .gitignore | 1 + CONTRIBUTING.md | 4 ---- build/use-lodash-es.js | 10 ++++++++++ package.json | 19 ++++++++++++------- 5 files changed, 33 insertions(+), 12 deletions(-) create mode 100644 build/use-lodash-es.js diff --git a/.babelrc b/.babelrc index 67435a531..8c6f5b857 100644 --- a/.babelrc +++ b/.babelrc @@ -18,7 +18,6 @@ "transform-es2015-parameters", ["transform-es2015-destructuring", { "loose": true }], "transform-es2015-block-scoping", - ["transform-es2015-modules-commonjs", { "loose": true }], "transform-object-rest-spread", "transform-react-jsx", "syntax-jsx" @@ -26,6 +25,16 @@ "env": { "test": { "plugins": ["istanbul"] + }, + "commonjs": { + "plugins": [ + ["transform-es2015-modules-commonjs", { "loose": true }] + ] + }, + "es": { + "plugins": [ + "./build/use-lodash-es" + ] } } } diff --git a/.gitignore b/.gitignore index f53a08f0e..2cd2cfe8d 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ dist lib .nyc_output coverage +es diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 342e92d5d..66c07e803 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -54,10 +54,6 @@ npm run lint Please open an issue with a proposal for a new feature or refactoring before starting on the work. We don't want you to waste your efforts on a pull request that we won't want to accept. -###Style - -[reactjs](https://github.com/reactjs) is trying to keep a standard style across its various projects, which can be found over in [eslint-config-reactjs](https://github.com/reactjs/eslint-config-reactjs). If you have a style change proposal, it should first be proposed there. If accepted, we will be happy to accept a PR to implement it here. - ## Submitting Changes * Open a new issue in the [Issue tracker](https://github.com/reactjs/react-redux/issues). diff --git a/build/use-lodash-es.js b/build/use-lodash-es.js new file mode 100644 index 000000000..ba4f2f52e --- /dev/null +++ b/build/use-lodash-es.js @@ -0,0 +1,10 @@ +module.exports = function () { + return { + visitor: { + ImportDeclaration(path) { + var source = path.node.source + source.value = source.value.replace(/^lodash($|\/)/, 'lodash-es$1') + } + } + } +} diff --git a/package.json b/package.json index 55c5c4c91..edb222a82 100644 --- a/package.json +++ b/package.json @@ -3,15 +3,18 @@ "version": "4.4.5", "description": "Official React bindings for Redux", "main": "./lib/index.js", + "module": "es/index.js", + "jsnext:main": "es/index.js", "scripts": { - "build:lib": "babel src --out-dir lib", - "build:umd": "cross-env NODE_ENV=development webpack src/index.js dist/react-redux.js", - "build:umd:min": "cross-env NODE_ENV=production webpack src/index.js dist/react-redux.min.js", - "build": "npm run build:lib && npm run build:umd && npm run build:umd:min && node ./prepublish", - "clean": "rimraf lib dist coverage", + "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 src/index.js dist/redux.js", + "build:umd:min": "cross-env BABEL_ENV=commonjs NODE_ENV=production webpack src/index.js dist/redux.min.js", + "build": "npm run build:commonjs && npm run build:es && npm run build:umd && npm run build:umd:min", + "clean": "rimraf lib dist es coverage", "lint": "eslint src test", "prepublish": "npm run clean && npm run build", - "test": "cross-env NODE_ENV=test mocha --compilers js:babel-register --recursive --require ./test/setup.js", + "test": "cross-env BABEL_ENV=commonjs NODE_ENV=test mocha --compilers js:babel-register --recursive --require ./test/setup.js", "test:watch": "npm test -- --watch", "test:cov": "cross-env NODE_ENV=test nyc npm test", "coverage": "nyc report --reporter=text-lcov > coverage.lcov && codecov" @@ -23,7 +26,8 @@ "files": [ "dist", "lib", - "src" + "src", + "es" ], "keywords": [ "react", @@ -95,6 +99,7 @@ "hoist-non-react-statics": "^1.0.3", "invariant": "^2.0.0", "lodash": "^4.2.0", + "lodash-es": "^4.2.0", "loose-envify": "^1.1.0" }, "peerDependencies": {