Skip to content

Commit 6337bf5

Browse files
TrySoundjquense
authored andcommitted
feat: support esm via package.json routes (#488)
BREAKING CHANGE: in environments where esm is supported importing from commonjs requires explicitly adding the `.default` after `require()` when resolving to the esm build Ref #77 Upgraded semantic-release-alt-publish-dir to get correct module field processing jquense/semantic-release-alt-publish-dir@795af9d
1 parent 9e3b2d3 commit 6337bf5

File tree

5 files changed

+102
-25
lines changed

5 files changed

+102
-25
lines changed

package.json

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,18 @@
22
"name": "react-transition-group",
33
"version": "3.0.0",
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",
@@ -72,6 +76,7 @@
7276
"babel-loader": "^8.0.5",
7377
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
7478
"babel-preset-jason": "^6.0.1",
79+
"cherry-pick": "^0.3.0",
7580
"cross-env": "^5.2.0",
7681
"enzyme": "^3.9.0",
7782
"enzyme-adapter-react-16": "^1.12.0",
@@ -97,7 +102,7 @@
97102
"rollup-plugin-size-snapshot": "^0.8.0",
98103
"rollup-plugin-terser": "^4.0.2",
99104
"semantic-release": "^15.9.16",
100-
"semantic-release-alt-publish-dir": "^2.1.1",
105+
"semantic-release-alt-publish-dir": "^3.0.0",
101106
"travis-deploy-once": "^5.0.8"
102107
},
103108
"release": {

rollup.config.js

Lines changed: 1 addition & 1 deletion
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

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';

src/umd.js

Lines changed: 0 additions & 4 deletions
This file was deleted.

yarn.lock

Lines changed: 88 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22
# yarn lockfile v1
33

44

5+
"@4c/file-butler@^2.1.0":
6+
version "2.3.0"
7+
resolved "https://registry.yarnpkg.com/@4c/file-butler/-/file-butler-2.3.0.tgz#123b22a59496d974cc18e2debce0445857bc0cec"
8+
integrity sha512-fGmitvq18UoSfKd0WfTZyG73JJZMV7Az9W/4QlsHt/zjssP2twvY2w3NAvzrDPHNezbsD3ufWJFyUQOL5mtfxQ==
9+
dependencies:
10+
cpy "^7.0.0"
11+
fs-extra "^7.0.1"
12+
globby "^9.0.0"
13+
yargs "^13.2.1"
14+
515
"@babel/cli@^7.4.3":
616
version "7.4.3"
717
resolved "https://registry.yarnpkg.com/@babel/cli/-/cli-7.4.3.tgz#353048551306ff42e5855b788b6ccd9477289774"
@@ -3712,6 +3722,16 @@ cheerio@^1.0.0-rc.2:
37123722
lodash "^4.15.0"
37133723
parse5 "^3.0.1"
37143724

3725+
cherry-pick@^0.3.0:
3726+
version "0.3.0"
3727+
resolved "https://registry.yarnpkg.com/cherry-pick/-/cherry-pick-0.3.0.tgz#b52626016c41197e6bffa0fc27074ae07988804a"
3728+
integrity sha512-N/+3l1f9yvD6Qpsj3jkBvSt5skLudVXGoSSQUy+yWoM13RjfVCvOiYLFr/JczOhTMwBPBuzE4WKCSxmYE1FFBg==
3729+
dependencies:
3730+
chalk "^2.4.1"
3731+
rimraf "^2.6.2"
3732+
tiny-glob "^0.2.0"
3733+
yargs "^11.0.0"
3734+
37153735
child-process-promise@^2.2.1:
37163736
version "2.2.1"
37173737
resolved "http://storage.mds.yandex.net/get-npm/38095/child-process-promise-2.2.1.tgz#4730a11ef610fad450b8f223c79d31d7bdad8074"
@@ -5872,6 +5892,11 @@ get-caller-file@^1.0.1:
58725892
version "1.0.2"
58735893
resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-1.0.2.tgz#f702e63127e7e231c160a80c1554acb70d5047e5"
58745894

5895+
get-caller-file@^2.0.1:
5896+
version "2.0.5"
5897+
resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e"
5898+
integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==
5899+
58755900
get-stdin@^6.0.0:
58765901
version "6.0.0"
58775902
resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-6.0.0.tgz#9e09bf712b360ab9225e812048f71fde9c89657b"
@@ -6007,6 +6032,11 @@ globals@^11.1.0, globals@^11.7.0:
60076032
version "11.7.0"
60086033
resolved "https://registry.yarnpkg.com/globals/-/globals-11.7.0.tgz#a583faa43055b1aca771914bf68258e2fc125673"
60096034

6035+
globalyzer@^0.1.0:
6036+
version "0.1.0"
6037+
resolved "https://registry.yarnpkg.com/globalyzer/-/globalyzer-0.1.0.tgz#cb76da79555669a1519d5a8edf093afaa0bf1465"
6038+
integrity sha512-40oNTM9UfG6aBmuKxk/giHn5nQ8RVz/SS4Ir6zgzOv9/qC3kKZ9v4etGTcJbEl/NyVQH7FGU7d+X1egr57Md2Q==
6039+
60106040
[email protected], globby@^8.0.0, globby@^8.0.1:
60116041
version "8.0.1"
60126042
resolved "https://registry.yarnpkg.com/globby/-/globby-8.0.1.tgz#b5ad48b8aa80b35b814fc1281ecc851f1d2b5b50"
@@ -6019,7 +6049,7 @@ [email protected], globby@^8.0.0, globby@^8.0.1:
60196049
pify "^3.0.0"
60206050
slash "^1.0.0"
60216051

6022-
globby@^9.2.0:
6052+
globby@^9.0.0, globby@^9.2.0:
60236053
version "9.2.0"
60246054
resolved "https://registry.yarnpkg.com/globby/-/globby-9.2.0.tgz#fd029a706c703d29bdd170f4b6db3a3f7a7cb63d"
60256055
integrity sha512-ollPHROa5mcxDEkwg6bPt3QbEf4pDQSNtd6JPL1YvOvAo/7/0VAm9TccUeoTmarjPw4pfUthSCqcyfNB1I3ZSg==
@@ -6033,6 +6063,11 @@ globby@^9.2.0:
60336063
pify "^4.0.1"
60346064
slash "^2.0.0"
60356065

6066+
globrex@^0.1.1:
6067+
version "0.1.2"
6068+
resolved "https://registry.yarnpkg.com/globrex/-/globrex-0.1.2.tgz#dd5d9ec826232730cd6793a5e33a9302985e6098"
6069+
integrity sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg==
6070+
60366071
got@^6.7.1:
60376072
version "6.7.1"
60386073
resolved "https://registry.yarnpkg.com/got/-/got-6.7.1.tgz#240cd05785a9a18e561dc1b44b41c763ef1e8db0"
@@ -9096,6 +9131,15 @@ os-locale@^3.0.0:
90969131
lcid "^2.0.0"
90979132
mem "^4.0.0"
90989133

9134+
os-locale@^3.1.0:
9135+
version "3.1.0"
9136+
resolved "https://registry.yarnpkg.com/os-locale/-/os-locale-3.1.0.tgz#a802a6ee17f24c10483ab9935719cef4ed16bf1a"
9137+
integrity sha512-Z8l3R4wYWM40/52Z+S265okfFj8Kt2cC2MKY+xNi3kFs+XGI7WXu/I309QQQYbRW4ijiZ+yxs9pqEhJh0DqW3Q==
9138+
dependencies:
9139+
execa "^1.0.0"
9140+
lcid "^2.0.0"
9141+
mem "^4.0.0"
9142+
90999143
os-tmpdir@^1.0.0, os-tmpdir@~1.0.2:
91009144
version "1.0.2"
91019145
resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274"
@@ -10504,6 +10548,11 @@ require-main-filename@^1.0.1:
1050410548
version "1.0.1"
1050510549
resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-1.0.1.tgz#97f717b69d48784f5f526a6c5aa8ffdda055a4d1"
1050610550

10551+
require-main-filename@^2.0.0:
10552+
version "2.0.0"
10553+
resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-2.0.0.tgz#d0b329ecc7cc0f61649f62215be69af54aa8989b"
10554+
integrity sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==
10555+
1050710556
requires-port@^1.0.0:
1050810557
version "1.0.0"
1050910558
resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff"
@@ -10805,10 +10854,12 @@ schema-utils@^1.0.0:
1080510854
ajv-errors "^1.0.0"
1080610855
ajv-keywords "^3.1.0"
1080710856

10808-
semantic-release-alt-publish-dir@^2.1.1:
10809-
version "2.1.2"
10810-
resolved "https://registry.yarnpkg.com/semantic-release-alt-publish-dir/-/semantic-release-alt-publish-dir-2.1.2.tgz#c96337ca619f8127b28688e004d89094807306f1"
10857+
semantic-release-alt-publish-dir@^3.0.0:
10858+
version "3.0.0"
10859+
resolved "https://registry.yarnpkg.com/semantic-release-alt-publish-dir/-/semantic-release-alt-publish-dir-3.0.0.tgz#3bac0fe7e9785696da64a3df4dbb8771d114b2d4"
10860+
integrity sha512-biwFhrNAX8uopreidrUUlJU+O7clxTB373Sb5Fh6wN+hn5dPtBoxXykiy59OivAWVcr4T1erM9WJDmIDlMXliQ==
1081110861
dependencies:
10862+
"@4c/file-butler" "^2.1.0"
1081210863
cpy "^7.0.0"
1081310864
fs-extra "^6.0.1"
1081410865

@@ -11689,6 +11740,14 @@ timers-browserify@^2.0.4:
1168911740
dependencies:
1169011741
setimmediate "^1.0.4"
1169111742

11743+
tiny-glob@^0.2.0:
11744+
version "0.2.6"
11745+
resolved "https://registry.yarnpkg.com/tiny-glob/-/tiny-glob-0.2.6.tgz#9e056e169d9788fe8a734dfa1ff02e9b92ed7eda"
11746+
integrity sha512-A7ewMqPu1B5PWwC3m7KVgAu96Ch5LA0w4SnEN/LbDREj/gAD0nPWboRbn8YoP9ISZXqeNAlMvKSKoEuhcfK3Pw==
11747+
dependencies:
11748+
globalyzer "^0.1.0"
11749+
globrex "^0.1.1"
11750+
1169211751
tiny-relative-date@^1.3.0:
1169311752
version "1.3.0"
1169411753
resolved "https://registry.yarnpkg.com/tiny-relative-date/-/tiny-relative-date-1.3.0.tgz#fa08aad501ed730f31cc043181d995c39a935e07"
@@ -12503,6 +12562,14 @@ yargs-parser@^11.1.1:
1250312562
camelcase "^5.0.0"
1250412563
decamelize "^1.2.0"
1250512564

12565+
yargs-parser@^13.0.0:
12566+
version "13.0.0"
12567+
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-13.0.0.tgz#3fc44f3e76a8bdb1cc3602e860108602e5ccde8b"
12568+
integrity sha512-w2LXjoL8oRdRQN+hOyppuXs+V/fVAYtpcrRxZuF7Kt/Oc+Jr2uAcVntaUTNT6w5ihoWfFDpNY8CPx1QskxZ/pw==
12569+
dependencies:
12570+
camelcase "^5.0.0"
12571+
decamelize "^1.2.0"
12572+
1250612573
yargs-parser@^9.0.2:
1250712574
version "9.0.2"
1250812575
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-9.0.2.tgz#9ccf6a43460fe4ed40a9bb68f48d43b8a68cc077"
@@ -12561,6 +12628,23 @@ yargs@^12.0.2:
1256112628
y18n "^3.2.1 || ^4.0.0"
1256212629
yargs-parser "^11.1.1"
1256312630

12631+
yargs@^13.2.1:
12632+
version "13.2.2"
12633+
resolved "https://registry.yarnpkg.com/yargs/-/yargs-13.2.2.tgz#0c101f580ae95cea7f39d927e7770e3fdc97f993"
12634+
integrity sha512-WyEoxgyTD3w5XRpAQNYUB9ycVH/PQrToaTXdYXRdOXvEy1l19br+VJsc0vcO8PTGg5ro/l/GY7F/JMEBmI0BxA==
12635+
dependencies:
12636+
cliui "^4.0.0"
12637+
find-up "^3.0.0"
12638+
get-caller-file "^2.0.1"
12639+
os-locale "^3.1.0"
12640+
require-directory "^2.1.1"
12641+
require-main-filename "^2.0.0"
12642+
set-blocking "^2.0.0"
12643+
string-width "^3.0.0"
12644+
which-module "^2.0.0"
12645+
y18n "^4.0.0"
12646+
yargs-parser "^13.0.0"
12647+
1256412648
yargs@^3.15.0:
1256512649
version "3.32.0"
1256612650
resolved "https://registry.yarnpkg.com/yargs/-/yargs-3.32.0.tgz#03088e9ebf9e756b69751611d2a5ef591482c995"

0 commit comments

Comments
 (0)