From 78ee3e71ae8bac5d924241ae2e7b794d82f2d946 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Tue, 20 Jun 2017 14:55:51 +0200 Subject: [PATCH] Added es build, which will get beneficial for es2015 modules aware bundlers like webpack 2+ and rollup --- .babelrc | 14 ++--------- .babelrc.js | 18 ++++++++++++++ .gitignore | 1 + CSSTransition/package.json | 7 ++++++ Transition/package.json | 7 ++++++ TransitionGroup/package.json | 7 ++++++ package.json | 17 +++++++++---- src/index.js | 7 +----- yarn.lock | 46 +++++++++++++++++++++++++++++++++++- 9 files changed, 101 insertions(+), 23 deletions(-) create mode 100644 .babelrc.js create mode 100644 CSSTransition/package.json create mode 100644 Transition/package.json create mode 100644 TransitionGroup/package.json diff --git a/.babelrc b/.babelrc index f359fcdc..04d04f8f 100644 --- a/.babelrc +++ b/.babelrc @@ -1,15 +1,5 @@ { "presets": [ - ["latest", { - "es2015": { "loose": true } - }], - "stage-2", - "react" - ], - "plugins": [ - "dev-expression", - "add-module-exports", - "transform-object-assign", - ["transform-react-remove-prop-types", { mode: "wrap" }] - ], + "./.babelrc.js" + ] } diff --git a/.babelrc.js b/.babelrc.js new file mode 100644 index 00000000..11e8835e --- /dev/null +++ b/.babelrc.js @@ -0,0 +1,18 @@ +const modules = process.env.BABEL_ENV === 'es' ? false : 'commonjs' + +const presets = [ + ['latest', { + es2015: { loose: true, modules } + }], + 'stage-2', + 'react' +] + +const plugins = [ + 'dev-expression', + 'add-module-exports', + 'transform-object-assign', + ['transform-react-remove-prop-types', { mode: 'wrap' }] +] + +module.exports = { plugins, presets } diff --git a/.gitignore b/.gitignore index 2c99def8..cb1fad8f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +/es /lib # Logs diff --git a/CSSTransition/package.json b/CSSTransition/package.json new file mode 100644 index 00000000..54d81306 --- /dev/null +++ b/CSSTransition/package.json @@ -0,0 +1,7 @@ +{ + "name": "react-transition-group/CSSTransition", + "private": true, + "main": "../lib/CSSTransition.js", + "module": "../es/CSSTransition.js", + "jsnext:main": "../es/CSSTransition.js" +} diff --git a/Transition/package.json b/Transition/package.json new file mode 100644 index 00000000..4c905f32 --- /dev/null +++ b/Transition/package.json @@ -0,0 +1,7 @@ +{ + "name": "react-transition-group/Transition", + "private": true, + "main": "../lib/Transition.js", + "module": "../es/Transition.js", + "jsnext:main": "../es/Transition.js" +} diff --git a/TransitionGroup/package.json b/TransitionGroup/package.json new file mode 100644 index 00000000..d328cd68 --- /dev/null +++ b/TransitionGroup/package.json @@ -0,0 +1,7 @@ +{ + "name": "react-transition-group/TransitionGroup", + "private": true, + "main": "../lib/TransitionGroup.js", + "module": "../es/TransitionGroup.js", + "jsnext:main": "../es/TransitionGroup.js" +} diff --git a/package.json b/package.json index 77e543e6..545ffe7b 100644 --- a/package.json +++ b/package.json @@ -3,10 +3,21 @@ "version": "2.0.0-beta.0", "description": "A react component toolset for managing animations", "main": "lib/index.js", + "module": "es/index.js", + "jsnext:main": "es/index.js", + "files": [ + "es", + "lib", + "CSSTransition", + "Transition", + "TransitionGroup", + ], "scripts": { "test": "jest --runInBand --verbose", "tdd": "jest --watch", - "build": "rimraf lib && babel src --out-dir lib && npm run build:dist", + "build": "rimraf es lib && npm run build:es && npm run build:cjs && npm run build:dist", + "build:es": "cross-env BABEL_ENV=es babel src --out-dir es", + "build:cjs": "cross-env BABEL_ENV=cjs babel src --out-dir lib", "build:dist": "rimraf lib/dist && webpack && NODE_ENV=production webpack -p", "lint": "eslint src test", "release": "release", @@ -65,6 +76,7 @@ "babel-preset-latest": "^6.24.0", "babel-preset-react": "^6.23.0", "babel-preset-stage-2": "^6.18.0", + "cross-env": "^5.0.1", "css-literal-loader": "^0.2.0", "css-loader": "^0.28.0", "eslint": "^3.17.1", @@ -82,9 +94,6 @@ "teaspoon": "^6.4.3", "webpack": "^2.2.1" }, - "release-script": { - "altPkgRootFolder": "lib" - }, "browserify": { "transform": [ "loose-envify" diff --git a/src/index.js b/src/index.js index a68a49ff..294f9913 100644 --- a/src/index.js +++ b/src/index.js @@ -2,9 +2,4 @@ import CSSTransition from './CSSTransition'; import TransitionGroup from './TransitionGroup'; import Transition from './Transition'; - -module.exports = { - Transition, - TransitionGroup, - CSSTransition, -}; +export { Transition, TransitionGroup, CSSTransition } diff --git a/yarn.lock b/yarn.lock index 0ee05e36..f9d2a683 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1758,6 +1758,21 @@ create-react-class@^15.5.2: fbjs "^0.8.9" object-assign "^4.1.1" +cross-env@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/cross-env/-/cross-env-5.0.1.tgz#ff4e72ea43b47da2486b43a7f2043b2609e44913" + dependencies: + cross-spawn "^5.1.0" + is-windows "^1.0.0" + +cross-spawn@^5.1.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449" + dependencies: + lru-cache "^4.0.1" + shebang-command "^1.2.0" + which "^1.2.9" + cryptiles@2.x.x: version "2.0.5" resolved "https://registry.yarnpkg.com/cryptiles/-/cryptiles-2.0.5.tgz#3bdfecdc608147c1c67202fa291e7dca59eaa3b8" @@ -3170,6 +3185,10 @@ is-utf8@^0.2.0: version "0.2.1" resolved "https://registry.yarnpkg.com/is-utf8/-/is-utf8-0.2.1.tgz#4b0da1442104d1b336340e80797e865cf39f7d72" +is-windows@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.1.tgz#310db70f742d259a16a369202b51af84233310d9" + isarray@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/isarray/-/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf" @@ -3724,6 +3743,13 @@ loose-envify@^1.0.0, loose-envify@^1.1.0, loose-envify@^1.3.1: dependencies: js-tokens "^3.0.0" +lru-cache@^4.0.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.1.1.tgz#622e32e82488b49279114a4f9ecf45e7cd6bba55" + dependencies: + pseudomap "^1.0.2" + yallist "^2.1.2" + macaddress@^0.2.8: version "0.2.8" resolved "https://registry.yarnpkg.com/macaddress/-/macaddress-0.2.8.tgz#5904dc537c39ec6dbefeae902327135fa8511f12" @@ -4628,6 +4654,10 @@ prr@~0.0.0: version "0.0.0" resolved "https://registry.yarnpkg.com/prr/-/prr-0.0.0.tgz#1a84b85908325501411853d0081ee3fa86e2926a" +pseudomap@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3" + public-encrypt@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/public-encrypt/-/public-encrypt-4.0.0.tgz#39f699f3a46560dd5ebacbca693caf7c65c18cc6" @@ -5145,6 +5175,16 @@ shallowequal@0.2.x, shallowequal@^0.2.2: dependencies: lodash.keys "^3.1.2" +shebang-command@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea" + dependencies: + shebang-regex "^1.0.0" + +shebang-regex@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3" + shelljs@^0.5.1: version "0.5.3" resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.5.3.tgz#c54982b996c76ef0c1e6b59fbdc5825f5b713113" @@ -5828,7 +5868,7 @@ which-module@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/which-module/-/which-module-1.0.0.tgz#bba63ca861948994ff307736089e3b96026c2a4f" -which@^1.2.12: +which@^1.2.12, which@^1.2.9: version "1.2.14" resolved "https://registry.yarnpkg.com/which/-/which-1.2.14.tgz#9a87c4378f03e827cecaf1acdf56c736c01c14e5" dependencies: @@ -5906,6 +5946,10 @@ y18n@^3.2.0, y18n@^3.2.1: version "3.2.1" resolved "https://registry.yarnpkg.com/y18n/-/y18n-3.2.1.tgz#6d15fba884c08679c0d77e88e7759e811e07fa41" +yallist@^2.1.2: + version "2.1.2" + resolved "https://registry.yarnpkg.com/yallist/-/yallist-2.1.2.tgz#1c11f9218f076089a47dd512f93c6699a6a81d52" + yargs-parser@^4.2.0: version "4.2.1" resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-4.2.1.tgz#29cceac0dc4f03c6c87b4a9f217dd18c9f74871c"