Skip to content

Commit ec456c1

Browse files
TrySoundjquense
authored andcommitted
feat: add esm support (#5)
* Support esm Currently `lib/es` contains commonjs modules. Babel config were missed there. New build system trapped me for a moment. Hopefully solution were simple and cherry-pick package fitted here well. * Add rimraf and upgrade cherry-pick with fixed dts
1 parent 0d117c7 commit ec456c1

File tree

3 files changed

+111
-6
lines changed

3 files changed

+111
-6
lines changed

.babelrc

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,15 @@
44
"targets": {}
55
}],
66
"@babel/typescript"
7-
]
7+
],
8+
"env": {
9+
"esm": {
10+
"presets": [
11+
["@4c", {
12+
"targets": {},
13+
"modules": false
14+
}]
15+
]
16+
}
17+
}
818
}

package.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
{
22
"name": "@restart/hooks",
33
"version": "0.3.1",
4-
"main": "lib/index.js",
5-
"types": "lib/index.d.ts",
6-
"module": "lib/es/index.js",
4+
"main": "lib/cjs/index.js",
5+
"types": "lib/cjs/index.d.ts",
6+
"module": "lib/esm/index.js",
77
"repository": "https://github.com/jquense/react-common-hooks.git",
88
"author": "Jason Quense <monastic.panic@gmail.com>",
99
"license": "MIT",
1010
"scripts": {
1111
"test": "jest",
1212
"tdd": "jest --watch",
13-
"build": "4c build src ",
13+
"build:pick": "cherry-pick --name=@restart/hooks --cwd=lib --input-dir=../src --cjs-dir=cjs --esm-dir=esm",
14+
"build": "rimraf lib && 4c build src && yarn build:pick",
1415
"prepublishOnly": "yarn build"
1516
},
1617
"jest": {
@@ -42,6 +43,7 @@
4243
"@types/jest": "^24.0.13",
4344
"@types/react": "^16.8.19",
4445
"babel-jest": "^24.8.0",
46+
"cherry-pick": "^0.4.0",
4547
"enzyme": "^3.9.0",
4648
"enzyme-adapter-react-16": "^1.13.2",
4749
"eslint": "^5.16.0",
@@ -51,6 +53,7 @@
5153
"prettier": "^1.17.1",
5254
"react": "^16.8.6",
5355
"react-dom": "^16.8.6",
56+
"rimraf": "^2.6.3",
5457
"rollout": "^0.1.0",
5558
"typescript": "^3.4.5"
5659
}

yarn.lock

Lines changed: 93 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1735,6 +1735,11 @@ ansi-regex@^4.0.0:
17351735
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-4.0.0.tgz#70de791edf021404c3fd615aa89118ae0432e5a9"
17361736
integrity sha512-iB5Dda8t/UqpPI/IjsejXu5jOGDrzn41wJyljwPH65VCIbk6+1BzFIMJGFwTNrYXT1CrD+B4l19U7awiQ8rk7w==
17371737

1738+
ansi-regex@^4.1.0:
1739+
version "4.1.0"
1740+
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-4.1.0.tgz#8b9f8f08cf1acb843756a839ca8c7e3168c51997"
1741+
integrity sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==
1742+
17381743
ansi-styles@^2.2.1:
17391744
version "2.2.1"
17401745
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe"
@@ -2332,6 +2337,16 @@ cheerio@^1.0.0-rc.2:
23322337
lodash "^4.15.0"
23332338
parse5 "^3.0.1"
23342339

2340+
cherry-pick@^0.4.0:
2341+
version "0.4.0"
2342+
resolved "https://registry.yarnpkg.com/cherry-pick/-/cherry-pick-0.4.0.tgz#35d8fbe52016813a2e06941771be2fc0e1a579b8"
2343+
integrity sha512-m26am20le2n2siOhrILux4TWi7CenuDufMu1HQ0T77c/30QBl7h4JvokJFX5qv6d8V7VKQUmm8XibIqacOb7rw==
2344+
dependencies:
2345+
chalk "^2.4.2"
2346+
rimraf "^2.6.3"
2347+
tiny-glob "^0.2.6"
2348+
yargs "^13.2.4"
2349+
23352350
chokidar@^2.0.3:
23362351
version "2.0.4"
23372352
resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-2.0.4.tgz#356ff4e2b0e8e43e322d18a372460bbcf3accd26"
@@ -2425,6 +2440,15 @@ cliui@^4.0.0:
24252440
strip-ansi "^4.0.0"
24262441
wrap-ansi "^2.0.0"
24272442

2443+
cliui@^5.0.0:
2444+
version "5.0.0"
2445+
resolved "https://registry.yarnpkg.com/cliui/-/cliui-5.0.0.tgz#deefcfdb2e800784aa34f46fa08e06851c7bbbc5"
2446+
integrity sha512-PYeGSEmmHM6zvoef2w8TPzlrnNpXIjTipYK780YswmIP9vjxmd6Y2a3CB2Ks6/AU8NHjZugXvo8w3oWM2qnwXA==
2447+
dependencies:
2448+
string-width "^3.1.0"
2449+
strip-ansi "^5.2.0"
2450+
wrap-ansi "^5.1.0"
2451+
24282452
clone@^1.0.2:
24292453
version "1.0.4"
24302454
resolved "https://registry.yarnpkg.com/clone/-/clone-1.0.4.tgz#da309cc263df15994c688ca902179ca3c7cd7c7e"
@@ -3951,6 +3975,11 @@ globals@^11.1.0, globals@^11.7.0:
39513975
resolved "https://registry.yarnpkg.com/globals/-/globals-11.8.0.tgz#c1ef45ee9bed6badf0663c5cb90e8d1adec1321d"
39523976
integrity sha512-io6LkyPVuzCHBSQV9fmOwxZkUk6nIaGmxheLDgmuFv89j0fm2aqDbIXKAGfzCMHqz3HLF2Zf8WSG6VqMh2qFmA==
39533977

3978+
globalyzer@^0.1.0:
3979+
version "0.1.4"
3980+
resolved "https://registry.yarnpkg.com/globalyzer/-/globalyzer-0.1.4.tgz#bc8e273afe1ac7c24eea8def5b802340c5cc534f"
3981+
integrity sha512-LeguVWaxgHN0MNbWC6YljNMzHkrCny9fzjmEUdnF1kQ7wATFD1RHFRqA1qxaX2tgxGENlcxjOflopBwj3YZiXA==
3982+
39543983
globby@^6.1.0:
39553984
version "6.1.0"
39563985
resolved "https://registry.yarnpkg.com/globby/-/globby-6.1.0.tgz#f5a6d70e8395e21c858fb0489d64df02424d506c"
@@ -4003,6 +4032,11 @@ globby@^9.2.0:
40034032
pify "^4.0.1"
40044033
slash "^2.0.0"
40054034

4035+
globrex@^0.1.1:
4036+
version "0.1.2"
4037+
resolved "https://registry.yarnpkg.com/globrex/-/globrex-0.1.2.tgz#dd5d9ec826232730cd6793a5e33a9302985e6098"
4038+
integrity sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg==
4039+
40064040
graceful-fs@^4.1.11, graceful-fs@^4.1.2:
40074041
version "4.1.11"
40084042
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658"
@@ -7204,7 +7238,7 @@ ret@~0.1.10:
72047238
resolved "https://registry.yarnpkg.com/ret/-/ret-0.1.15.tgz#b8a4825d5bdb1fc3f6f53c2bc33f81388681c7bc"
72057239
integrity sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==
72067240

7207-
rimraf@2.6.3, rimraf@^2.6.2:
7241+
rimraf@2.6.3, rimraf@^2.6.2, rimraf@^2.6.3:
72087242
version "2.6.3"
72097243
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.3.tgz#b2d104fe0d8fb27cf9e0a1cda8262dd3833c6cab"
72107244
integrity sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==
@@ -7655,6 +7689,15 @@ string-width@^3.0.0:
76557689
is-fullwidth-code-point "^2.0.0"
76567690
strip-ansi "^5.0.0"
76577691

7692+
string-width@^3.1.0:
7693+
version "3.1.0"
7694+
resolved "https://registry.yarnpkg.com/string-width/-/string-width-3.1.0.tgz#22767be21b62af1081574306f69ac51b62203961"
7695+
integrity sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==
7696+
dependencies:
7697+
emoji-regex "^7.0.1"
7698+
is-fullwidth-code-point "^2.0.0"
7699+
strip-ansi "^5.1.0"
7700+
76587701
string.prototype.trim@^1.1.2:
76597702
version "1.1.2"
76607703
resolved "https://registry.yarnpkg.com/string.prototype.trim/-/string.prototype.trim-1.1.2.tgz#d04de2c89e137f4d7d206f086b5ed2fae6be8cea"
@@ -7706,6 +7749,13 @@ strip-ansi@^5.0.0:
77067749
dependencies:
77077750
ansi-regex "^4.0.0"
77087751

7752+
strip-ansi@^5.1.0, strip-ansi@^5.2.0:
7753+
version "5.2.0"
7754+
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-5.2.0.tgz#8c9a536feb6afc962bdfa5b104a5091c1ad9c0ae"
7755+
integrity sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==
7756+
dependencies:
7757+
ansi-regex "^4.1.0"
7758+
77097759
strip-bom@^2.0.0:
77107760
version "2.0.0"
77117761
resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-2.0.0.tgz#6219a85616520491f35788bdbf1447a99c7e6b0e"
@@ -7843,6 +7893,14 @@ through@2, "through@>=2.2.7 <3", through@^2.3.6:
78437893
resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5"
78447894
integrity sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=
78457895

7896+
tiny-glob@^0.2.6:
7897+
version "0.2.6"
7898+
resolved "https://registry.yarnpkg.com/tiny-glob/-/tiny-glob-0.2.6.tgz#9e056e169d9788fe8a734dfa1ff02e9b92ed7eda"
7899+
integrity sha512-A7ewMqPu1B5PWwC3m7KVgAu96Ch5LA0w4SnEN/LbDREj/gAD0nPWboRbn8YoP9ISZXqeNAlMvKSKoEuhcfK3Pw==
7900+
dependencies:
7901+
globalyzer "^0.1.0"
7902+
globrex "^0.1.1"
7903+
78467904
title-case@^2.1.0:
78477905
version "2.1.1"
78487906
resolved "https://registry.yarnpkg.com/title-case/-/title-case-2.1.1.tgz#3e127216da58d2bc5becf137ab91dae3a7cd8faa"
@@ -8235,6 +8293,15 @@ wrap-ansi@^3.0.1:
82358293
string-width "^2.1.1"
82368294
strip-ansi "^4.0.0"
82378295

8296+
wrap-ansi@^5.1.0:
8297+
version "5.1.0"
8298+
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-5.1.0.tgz#1fd1f67235d5b6d0fee781056001bfb694c03b09"
8299+
integrity sha512-QC1/iN/2/RPVJ5jYK8BGttj5z83LmSKmvbvrXPNCLZSEb32KKVDJDl/MOt2N01qU2H/FkzEa9PKto1BqDjtd7Q==
8300+
dependencies:
8301+
ansi-styles "^3.2.0"
8302+
string-width "^3.0.0"
8303+
strip-ansi "^5.0.0"
8304+
82388305
wrappy@1:
82398306
version "1.0.2"
82408307
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
@@ -8299,6 +8366,14 @@ yargs-parser@^13.0.0:
82998366
camelcase "^5.0.0"
83008367
decamelize "^1.2.0"
83018368

8369+
yargs-parser@^13.1.0:
8370+
version "13.1.1"
8371+
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-13.1.1.tgz#d26058532aa06d365fe091f6a1fc06b2f7e5eca0"
8372+
integrity sha512-oVAVsHz6uFrg3XQheFII8ESO2ssAf9luWuAd6Wexsu4F3OtIW0o8IribPXYrD4WC24LWtPrJlGy87y5udK+dxQ==
8373+
dependencies:
8374+
camelcase "^5.0.0"
8375+
decamelize "^1.2.0"
8376+
83028377
yargs@^12.0.2:
83038378
version "12.0.5"
83048379
resolved "https://registry.yarnpkg.com/yargs/-/yargs-12.0.5.tgz#05f5997b609647b64f66b81e3b4b10a368e7ad13"
@@ -8334,6 +8409,23 @@ yargs@^13.2.1:
83348409
y18n "^4.0.0"
83358410
yargs-parser "^13.0.0"
83368411

8412+
yargs@^13.2.4:
8413+
version "13.2.4"
8414+
resolved "https://registry.yarnpkg.com/yargs/-/yargs-13.2.4.tgz#0b562b794016eb9651b98bd37acf364aa5d6dc83"
8415+
integrity sha512-HG/DWAJa1PAnHT9JAhNa8AbAv3FPaiLzioSjCcmuXXhP8MlpHO5vwls4g4j6n30Z74GVQj8Xa62dWVx1QCGklg==
8416+
dependencies:
8417+
cliui "^5.0.0"
8418+
find-up "^3.0.0"
8419+
get-caller-file "^2.0.1"
8420+
os-locale "^3.1.0"
8421+
require-directory "^2.1.1"
8422+
require-main-filename "^2.0.0"
8423+
set-blocking "^2.0.0"
8424+
string-width "^3.0.0"
8425+
which-module "^2.0.0"
8426+
y18n "^4.0.0"
8427+
yargs-parser "^13.1.0"
8428+
83378429
yup@^0.27.0:
83388430
version "0.27.0"
83398431
resolved "https://registry.yarnpkg.com/yup/-/yup-0.27.0.tgz#f8cb198c8e7dd2124beddc2457571329096b06e7"

0 commit comments

Comments
 (0)