Skip to content

Commit

Permalink
Add package.json#exports (#354)
Browse files Browse the repository at this point in the history
  • Loading branch information
Andarist committed Nov 10, 2022
1 parent cd87f81 commit 41d10b2
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 14 deletions.
7 changes: 7 additions & 0 deletions .changeset/light-turtles-peel.md
@@ -0,0 +1,7 @@
---
'react-textarea-autosize': minor
---

`exports` field has been added to the `package.json` manifest.

Thanks to this, the package now includes a `worker` condition that can be utilized by properly configured bundlers when targeting worker-like environments. It fixes the issue with browser-specific files being prioritized by some bundlers when targeting workers.
27 changes: 24 additions & 3 deletions package.json
Expand Up @@ -17,9 +17,19 @@
"main": "dist/react-textarea-autosize.cjs.js",
"module": "dist/react-textarea-autosize.esm.js",
"browser": {
"./dist/react-textarea-autosize.cjs.js": "./dist/react-textarea-autosize.browser.cjs.js",
"./dist/react-textarea-autosize.esm.js": "./dist/react-textarea-autosize.browser.esm.js"
},
"exports": {
".": {
"module": {
"worker": "./dist/react-textarea-autosize.worker.esm.js",
"browser": "./dist/react-textarea-autosize.browser.esm.js",
"default": "./dist/react-textarea-autosize.esm.js"
},
"default": "./dist/react-textarea-autosize.cjs.js"
},
"./package.json": "./package.json"
},
"sideEffects": false,
"files": [
"dist"
Expand Down Expand Up @@ -60,7 +70,7 @@
"@babel/preset-typescript": "^7.10.4",
"@changesets/changelog-github": "^0.4.4",
"@changesets/cli": "^2.22.0",
"@preconstruct/cli": "^2.0.5",
"@preconstruct/cli": "^2.2.2",
"@testing-library/jest-dom": "^5.9.0",
"@testing-library/react": "^10.1.0",
"@types/react": "^16.9.35",
Expand Down Expand Up @@ -88,5 +98,16 @@
"engines": {
"node": ">=10"
},
"packageManager": "yarn@3.1.1"
"packageManager": "yarn@3.1.1",
"preconstruct": {
"exports": {
"envConditions": [
"browser",
"worker"
]
},
"___experimentalFlags_WILL_CHANGE_IN_PATCH": {
"exports": true
}
}
}
71 changes: 60 additions & 11 deletions yarn.lock
Expand Up @@ -3120,9 +3120,9 @@ __metadata:
languageName: node
linkType: hard

"@preconstruct/cli@npm:^2.0.5":
version: 2.0.5
resolution: "@preconstruct/cli@npm:2.0.5"
"@preconstruct/cli@npm:^2.2.2":
version: 2.2.2
resolution: "@preconstruct/cli@npm:2.2.2"
dependencies:
"@babel/code-frame": ^7.5.5
"@babel/core": ^7.7.7
Expand All @@ -3132,7 +3132,7 @@ __metadata:
"@rollup/plugin-alias": ^3.1.1
"@rollup/plugin-commonjs": ^15.0.0
"@rollup/plugin-json": ^4.1.0
"@rollup/plugin-node-resolve": ^9.0.0
"@rollup/plugin-node-resolve": ^11.2.1
"@rollup/plugin-replace": ^2.4.1
builtin-modules: ^3.1.0
chalk: ^4.1.0
Expand Down Expand Up @@ -3163,7 +3163,7 @@ __metadata:
v8-compile-cache: ^2.1.1
bin:
preconstruct: bin.js
checksum: 0f5c8fe4da980f2fe54da0c068da0e4c05b5f886deca762dd38fa5bde757d47fe6b48b0f7639358f717ce221f30260be1b0896066cd2e618a9f1716f13ab681b
checksum: 6cc89bd472d7d95dc97e447f6b01923217bdc7af8b7361183c33904018600d30daa5956d79bdbfe54fdbd5b17b8b70f4ca62f6f9fc9daa0c8234558438721acf
languageName: node
linkType: hard

Expand Down Expand Up @@ -3218,19 +3218,19 @@ __metadata:
languageName: node
linkType: hard

"@rollup/plugin-node-resolve@npm:^9.0.0":
version: 9.0.0
resolution: "@rollup/plugin-node-resolve@npm:9.0.0"
"@rollup/plugin-node-resolve@npm:^11.2.1":
version: 11.2.1
resolution: "@rollup/plugin-node-resolve@npm:11.2.1"
dependencies:
"@rollup/pluginutils": ^3.1.0
"@types/resolve": 1.17.1
builtin-modules: ^3.1.0
deepmerge: ^4.2.2
is-module: ^1.0.0
resolve: ^1.17.0
resolve: ^1.19.0
peerDependencies:
rollup: ^1.20.0||^2.0.0
checksum: 5f05cb85b9f92d1cedf118ff7e1350bafebb48a95e8a4642b49d0836397e1db84df744b64b09cbc3d1b69d9f1ede77e299b9cad60f769d00b6966b0a9cc35800
checksum: 6f3b3ecf9a0596a5db4212984bdeb13bb7612693602407e9457ada075dea5a5f2e4e124c592352cf27066a88b194de9b9a95390149b52cf335d5b5e17b4e265b
languageName: node
linkType: hard

Expand Down Expand Up @@ -7715,6 +7715,15 @@ fsevents@~2.3.1:
languageName: node
linkType: hard

"is-core-module@npm:^2.9.0":
version: 2.11.0
resolution: "is-core-module@npm:2.11.0"
dependencies:
has: ^1.0.3
checksum: f96fd490c6b48eb4f6d10ba815c6ef13f410b0ba6f7eb8577af51697de523e5f2cd9de1c441b51d27251bf0e4aebc936545e33a5d26d5d51f28d25698d4a8bab
languageName: node
linkType: hard

"is-data-descriptor@npm:^0.1.4":
version: 0.1.4
resolution: "is-data-descriptor@npm:0.1.4"
Expand Down Expand Up @@ -10363,6 +10372,13 @@ fsevents@~2.3.1:
languageName: node
linkType: hard

"path-parse@npm:^1.0.7":
version: 1.0.7
resolution: "path-parse@npm:1.0.7"
checksum: 49abf3d81115642938a8700ec580da6e830dde670be21893c62f4e10bd7dd4c3742ddc603fe24f898cba7eb0c6bc1777f8d9ac14185d34540c6d4d80cd9cae8a
languageName: node
linkType: hard

"path-to-regexp@npm:2.2.1":
version: 2.2.1
resolution: "path-to-regexp@npm:2.2.1"
Expand Down Expand Up @@ -11227,7 +11243,7 @@ fsevents@~2.3.1:
"@babel/runtime": ^7.10.2
"@changesets/changelog-github": ^0.4.4
"@changesets/cli": ^2.22.0
"@preconstruct/cli": ^2.0.5
"@preconstruct/cli": ^2.2.2
"@testing-library/jest-dom": ^5.9.0
"@testing-library/react": ^10.1.0
"@types/react": ^16.9.35
Expand Down Expand Up @@ -11571,6 +11587,19 @@ fsevents@~2.3.1:
languageName: node
linkType: hard

"resolve@npm:^1.19.0":
version: 1.22.1
resolution: "resolve@npm:1.22.1"
dependencies:
is-core-module: ^2.9.0
path-parse: ^1.0.7
supports-preserve-symlinks-flag: ^1.0.0
bin:
resolve: bin/resolve
checksum: 07af5fc1e81aa1d866cbc9e9460fbb67318a10fa3c4deadc35c3ad8a898ee9a71a86a65e4755ac3195e0ea0cfbe201eb323ebe655ce90526fd61917313a34e4e
languageName: node
linkType: hard

"resolve@patch:resolve@^1.10.0#~builtin<compat/resolve>, resolve@patch:resolve@^1.12.0#~builtin<compat/resolve>, resolve@patch:resolve@^1.17.0#~builtin<compat/resolve>, resolve@patch:resolve@^1.3.2#~builtin<compat/resolve>, resolve@patch:resolve@^1.8.1#~builtin<compat/resolve>":
version: 1.17.0
resolution: "resolve@patch:resolve@npm%3A1.17.0#~builtin<compat/resolve>::version=1.17.0&hash=07638b"
Expand All @@ -11580,6 +11609,19 @@ fsevents@~2.3.1:
languageName: node
linkType: hard

"resolve@patch:resolve@^1.19.0#~builtin<compat/resolve>":
version: 1.22.1
resolution: "resolve@patch:resolve@npm%3A1.22.1#~builtin<compat/resolve>::version=1.22.1&hash=07638b"
dependencies:
is-core-module: ^2.9.0
path-parse: ^1.0.7
supports-preserve-symlinks-flag: ^1.0.0
bin:
resolve: bin/resolve
checksum: 5656f4d0bedcf8eb52685c1abdf8fbe73a1603bb1160a24d716e27a57f6cecbe2432ff9c89c2bd57542c3a7b9d14b1882b73bfe2e9d7849c9a4c0b8b39f02b8b
languageName: node
linkType: hard

"restore-cursor@npm:^3.1.0":
version: 3.1.0
resolution: "restore-cursor@npm:3.1.0"
Expand Down Expand Up @@ -12570,6 +12612,13 @@ fsevents@~2.3.1:
languageName: node
linkType: hard

"supports-preserve-symlinks-flag@npm:^1.0.0":
version: 1.0.0
resolution: "supports-preserve-symlinks-flag@npm:1.0.0"
checksum: 53b1e247e68e05db7b3808b99b892bd36fb096e6fba213a06da7fab22045e97597db425c724f2bbd6c99a3c295e1e73f3e4de78592289f38431049e1277ca0ae
languageName: node
linkType: hard

"svgo@npm:^1.0.0, svgo@npm:^1.3.2":
version: 1.3.2
resolution: "svgo@npm:1.3.2"
Expand Down

0 comments on commit 41d10b2

Please sign in to comment.