Skip to content

Commit ef3e357

Browse files
TrySoundsilvenon
authored andcommitted
feat: support ESM (tree-shaking) (#455)
Ref #77 Closes #455
1 parent fd7b869 commit ef3e357

File tree

6 files changed

+47
-26
lines changed

6 files changed

+47
-26
lines changed

.size-snapshot.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"./lib/dist/react-transition-group.js": {
3-
"bundled": 79410,
4-
"minified": 22589,
5-
"gzipped": 6905
3+
"bundled": 79947,
4+
"minified": 22686,
5+
"gzipped": 6939
66
},
77
"./lib/dist/react-transition-group.min.js": {
8-
"bundled": 46139,
9-
"minified": 14975,
10-
"gzipped": 4685
8+
"bundled": 45963,
9+
"minified": 15056,
10+
"gzipped": 4715
1111
}
1212
}

package.json

+8-3
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,18 @@
22
"name": "react-transition-group",
33
"version": "2.6.1",
44
"description": "A react component toolset for managing animations",
5-
"main": "lib/index.js",
5+
"main": "lib/cjs/index.js",
6+
"module": "lib/esm/index.js",
67
"scripts": {
78
"test": "npm run lint && npm run testonly",
89
"testonly": "jest --verbose",
910
"tdd": "jest --watch",
10-
"build": "babel src --out-dir lib --delete-dir-on-start && npm run build:dist && cp README.md LICENSE ./lib",
11+
"build": "rimraf lib && yarn build:cjs && yarn build:esm && yarn build:pick && yarn build:dist && cp README.md LICENSE ./lib",
1112
"build:docs": "npm -C www run build",
12-
"build:dist": "cross-env BABEL_ENV=esm yarn rollup -c",
13+
"build:cjs": "babel src --out-dir lib/cjs",
14+
"build:esm": "cross-env BABEL_ENV=esm babel src --out-dir lib/esm",
15+
"build:pick": "cherry-pick --name=react-transition-group --cwd=lib --input-dir=../src --cjs-dir=cjs --esm-dir=esm",
16+
"build:dist": "cross-env BABEL_ENV=esm rollup -c",
1317
"bootstrap": "yarn && yarn --cwd www",
1418
"lint": "eslint src test",
1519
"release": "release",
@@ -74,6 +78,7 @@
7478
"babel-loader": "^8.0.2",
7579
"babel-plugin-transform-react-remove-prop-types": "^0.4.18",
7680
"babel-preset-jason": "^6.0.1",
81+
"cherry-pick": "^0.3.0",
7782
"cross-env": "^5.2.0",
7883
"enzyme": "^3.6.0",
7984
"enzyme-adapter-react-16": "^1.5.0",

rollup.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import replace from 'rollup-plugin-replace';
55
import { sizeSnapshot } from 'rollup-plugin-size-snapshot';
66
import { terser } from 'rollup-plugin-terser';
77

8-
const input = './src/umd.js';
8+
const input = './src/index.js';
99
const name = 'ReactTransitionGroup';
1010
const globals = {
1111
react: 'React',

src/index.js

+4-12
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';

src/umd.js

-4
This file was deleted.

yarn.lock

+28
Original file line numberDiff line numberDiff line change
@@ -3419,6 +3419,16 @@ cheerio@^1.0.0-rc.2:
34193419
lodash "^4.15.0"
34203420
parse5 "^3.0.1"
34213421

3422+
cherry-pick@^0.3.0:
3423+
version "0.3.0"
3424+
resolved "https://registry.yarnpkg.com/cherry-pick/-/cherry-pick-0.3.0.tgz#b52626016c41197e6bffa0fc27074ae07988804a"
3425+
integrity sha512-N/+3l1f9yvD6Qpsj3jkBvSt5skLudVXGoSSQUy+yWoM13RjfVCvOiYLFr/JczOhTMwBPBuzE4WKCSxmYE1FFBg==
3426+
dependencies:
3427+
chalk "^2.4.1"
3428+
rimraf "^2.6.2"
3429+
tiny-glob "^0.2.0"
3430+
yargs "^11.0.0"
3431+
34223432
child-process-promise@^2.2.1:
34233433
version "2.2.1"
34243434
resolved "http://storage.mds.yandex.net/get-npm/38095/child-process-promise-2.2.1.tgz#4730a11ef610fad450b8f223c79d31d7bdad8074"
@@ -5634,6 +5644,11 @@ globals@^9.18.0:
56345644
version "9.18.0"
56355645
resolved "https://registry.yarnpkg.com/globals/-/globals-9.18.0.tgz#aa3896b3e69b487f17e31ed2143d69a8e30c2d8a"
56365646

5647+
globalyzer@^0.1.0:
5648+
version "0.1.0"
5649+
resolved "https://registry.yarnpkg.com/globalyzer/-/globalyzer-0.1.0.tgz#cb76da79555669a1519d5a8edf093afaa0bf1465"
5650+
integrity sha512-40oNTM9UfG6aBmuKxk/giHn5nQ8RVz/SS4Ir6zgzOv9/qC3kKZ9v4etGTcJbEl/NyVQH7FGU7d+X1egr57Md2Q==
5651+
56375652
globby@8.0.1, globby@^8.0.0, globby@^8.0.1:
56385653
version "8.0.1"
56395654
resolved "https://registry.yarnpkg.com/globby/-/globby-8.0.1.tgz#b5ad48b8aa80b35b814fc1281ecc851f1d2b5b50"
@@ -5657,6 +5672,11 @@ globby@^5.0.0:
56575672
pify "^2.0.0"
56585673
pinkie-promise "^2.0.0"
56595674

5675+
globrex@^0.1.1:
5676+
version "0.1.2"
5677+
resolved "https://registry.yarnpkg.com/globrex/-/globrex-0.1.2.tgz#dd5d9ec826232730cd6793a5e33a9302985e6098"
5678+
integrity sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg==
5679+
56605680
got@^6.7.1:
56615681
version "6.7.1"
56625682
resolved "https://registry.yarnpkg.com/got/-/got-6.7.1.tgz#240cd05785a9a18e561dc1b44b41c763ef1e8db0"
@@ -11101,6 +11121,14 @@ timers-browserify@^2.0.4:
1110111121
dependencies:
1110211122
setimmediate "^1.0.4"
1110311123

11124+
tiny-glob@^0.2.0:
11125+
version "0.2.6"
11126+
resolved "https://registry.yarnpkg.com/tiny-glob/-/tiny-glob-0.2.6.tgz#9e056e169d9788fe8a734dfa1ff02e9b92ed7eda"
11127+
integrity sha512-A7ewMqPu1B5PWwC3m7KVgAu96Ch5LA0w4SnEN/LbDREj/gAD0nPWboRbn8YoP9ISZXqeNAlMvKSKoEuhcfK3Pw==
11128+
dependencies:
11129+
globalyzer "^0.1.0"
11130+
globrex "^0.1.1"
11131+
1110411132
tiny-relative-date@^1.3.0:
1110511133
version "1.3.0"
1110611134
resolved "https://registry.yarnpkg.com/tiny-relative-date/-/tiny-relative-date-1.3.0.tgz#fa08aad501ed730f31cc043181d995c39a935e07"

0 commit comments

Comments
 (0)