Skip to content

Commit 23305cc

Browse files
committed
build: Added es build, which will get beneficial for es2015 modules aware bundlers like webpack 2+ and rollup
1 parent 2043cf7 commit 23305cc

File tree

6 files changed

+719
-773
lines changed

6 files changed

+719
-773
lines changed

.babelrc

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
11
{
22
"presets": [
3-
["latest", {
4-
"es2015": { "loose": true }
5-
}],
6-
"stage-2",
7-
"react"
8-
],
9-
"plugins": [
10-
"dev-expression",
11-
"add-module-exports",
12-
"transform-object-assign",
13-
["transform-react-remove-prop-types", { "mode": "wrap" }]
3+
"./.babelrc.js"
144
]
155
}

.babelrc.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const { NODE_ENV, BABEL_ENV } = process.env
2+
const cjs = NODE_ENV === 'test' || BABEL_ENV === 'cjs'
3+
4+
const presets = [
5+
['latest', {
6+
es2015: { loose: true, modules: false }
7+
}],
8+
'stage-2',
9+
'react'
10+
]
11+
12+
const plugins = [
13+
'dev-expression',
14+
'transform-object-assign',
15+
['transform-react-remove-prop-types', { mode: 'wrap' }],
16+
cjs && 'add-module-exports',
17+
cjs && 'transform-es2015-modules-commonjs',
18+
].filter(Boolean)
19+
20+
module.exports = { plugins, presets }

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/lib
2+
/esm
23

34
# Logs
45
logs

package.json

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,20 @@
33
"version": "2.3.1",
44
"description": "A react component toolset for managing animations",
55
"main": "lib/index.js",
6+
"module": "lib/index.mjs",
67
"scripts": {
78
"test": "npm run lint && npm run testonly",
89
"testonly": "jest --verbose",
910
"tdd": "jest --watch",
10-
"build": "rimraf lib && babel src --out-dir lib && npm run build:dist && cp README.md LICENSE ./lib",
11+
"prebuild": "rimraf lib esm",
12+
"build": "npm run build:cjs && npm run build:esm && npm run build:mjs && npm run build:dist && cp README.md LICENSE ./lib",
13+
"build:esm": "cross-env BABEL_ENV=esm babel src --out-dir esm",
14+
"build:cjs": "cross-env BABEL_ENV=cjs babel src --out-dir lib",
15+
"build:mjs": "copy-mjs && rimraf esm",
16+
"build:dist": "webpack && NODE_ENV=production webpack -p",
1117
"build:docs": "npm -C www run build",
12-
"build:dist": "rimraf lib/dist && webpack && NODE_ENV=production webpack -p",
1318
"bootstrap": "yarn && yarn --cwd www",
1419
"lint": "eslint src test",
15-
"release": "release",
16-
"release:next": "release --preid beta --tag next",
1720
"deploy-docs": "npm -C www run deploy",
1821
"start": "npm -C www run develop",
1922
"storybook": "start-storybook -p 6006",
@@ -77,11 +80,14 @@
7780
"babel-loader": "^6.4.1",
7881
"babel-plugin-add-module-exports": "^0.2.1",
7982
"babel-plugin-dev-expression": "^0.2.1",
83+
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.2",
8084
"babel-plugin-transform-object-assign": "^6.22.0",
8185
"babel-plugin-transform-react-remove-prop-types": "^0.4.5",
8286
"babel-preset-latest": "^6.24.0",
8387
"babel-preset-react": "^6.23.0",
8488
"babel-preset-stage-2": "^6.18.0",
89+
"copy-mjs": "^0.1.0",
90+
"cross-env": "^5.0.1",
8591
"enzyme": "^3.0.0",
8692
"enzyme-adapter-react-16": "^1.0.0",
8793
"eslint": "^3.17.1",
@@ -97,10 +103,9 @@
97103
"react": "^16.0.0",
98104
"react-dom": "^16.0.0",
99105
"react-test-renderer": "^16.0.0",
100-
"release-script": "^1.0.2",
101106
"rimraf": "^2.6.1",
102107
"semantic-release": "^15.1.7",
103-
"semantic-release-alt-publish-dir": "^2.1.1",
108+
"semantic-release-alt-publish-dir": "^2.1.2",
104109
"sinon": "^2.1.0",
105110
"travis-deploy-once": "^4.4.1",
106111
"webpack": "^3.6.0",

src/index.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
1-
import CSSTransition from './CSSTransition';
2-
import ReplaceTransition from './ReplaceTransition';
3-
import TransitionGroup from './TransitionGroup';
4-
import Transition from './Transition';
5-
6-
7-
module.exports = {
8-
Transition,
9-
TransitionGroup,
10-
ReplaceTransition,
11-
CSSTransition,
12-
};
1+
export { default as CSSTransition } from './CSSTransition';
2+
export { default as ReplaceTransition } from './ReplaceTransition';
3+
export { default as TransitionGroup } from './TransitionGroup';
4+
export { default as Transition } from './Transition';

0 commit comments

Comments
 (0)