Skip to content

Commit

Permalink
Added package.json#exports to all packages (#3727)
Browse files Browse the repository at this point in the history
  • Loading branch information
Andarist authored Dec 28, 2022
1 parent 8509699 commit 5fb3c68
Show file tree
Hide file tree
Showing 15 changed files with 175 additions and 12 deletions.
11 changes: 11 additions & 0 deletions .changeset/quick-lizards-burn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
'@xstate/analytics': minor
'@xstate/graph': minor
'@xstate/immer': minor
'@xstate/inspect': minor
'@xstate/scxml': minor
'@xstate/svelte': minor
'@xstate/test': minor
---

`exports` field has been added to the `package.json` manifest. It limits what files can be imported from a package - it's no longer possible to import from files that are not considered to be a part of the public API.
8 changes: 8 additions & 0 deletions .changeset/quick-lizards-thrive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'xstate': minor
'@xstate/fsm': minor
'@xstate/react': minor
'@xstate/vue': minor
---

`exports` field has been added to the `package.json` manifest. It limits what files can be imported from a package - it's no longer possible to import from files that are not considered to be a part of the public API.
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
],
"globals": {
"react": "React"
},
"exports": true,
"___experimentalFlags_WILL_CHANGE_IN_PATCH": {
"exports": true
}
},
"scripts": {
Expand Down Expand Up @@ -49,7 +53,7 @@
"@changesets/cli": "^2.19.0",
"@manypkg/cli": "^0.16.1",
"@manypkg/get-packages": "^1.1.3",
"@preconstruct/cli": "^2.1.5",
"@preconstruct/cli": "^2.2.2",
"@testing-library/jest-dom": "^5.11.9",
"@testing-library/vue": "^6.4.0",
"@types/jest": "^24.0.23",
Expand Down
23 changes: 23 additions & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,29 @@
"main": "dist/xstate.cjs.js",
"module": "dist/xstate.esm.js",
"umd:main": "dist/xstate.umd.min.js",
"exports": {
".": {
"module": "./dist/xstate.esm.js",
"default": "./dist/xstate.cjs.js"
},
"./actors": {
"module": "./actors/dist/xstate-actors.esm.js",
"default": "./actors/dist/xstate-actors.cjs.js"
},
"./guards": {
"module": "./guards/dist/xstate-guards.esm.js",
"default": "./guards/dist/xstate-guards.cjs.js"
},
"./actions": {
"module": "./actions/dist/xstate-actions.esm.js",
"default": "./actions/dist/xstate-actions.cjs.js"
},
"./dev": {
"module": "./dev/dist/xstate-dev.esm.js",
"default": "./dev/dist/xstate-dev.cjs.js"
},
"./package.json": "./package.json"
},
"sideEffects": false,
"funding": {
"type": "opencollective",
Expand Down
7 changes: 7 additions & 0 deletions packages/xstate-analytics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@
"license": "MIT",
"main": "dist/xstate-analytics.cjs.js",
"module": "dist/xstate-analytics.esm.js",
"exports": {
".": {
"module": "./dist/xstate-analytics.esm.js",
"default": "./dist/xstate-analytics.cjs.js"
},
"./package.json": "./package.json"
},
"sideEffects": false,
"files": [
"dist"
Expand Down
7 changes: 7 additions & 0 deletions packages/xstate-fsm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@
"license": "MIT",
"main": "dist/xstate-fsm.cjs.js",
"module": "dist/xstate-fsm.esm.js",
"exports": {
".": {
"module": "./dist/xstate-fsm.esm.js",
"default": "./dist/xstate-fsm.cjs.js"
},
"./package.json": "./package.json"
},
"sideEffects": false,
"files": [
"dist"
Expand Down
7 changes: 7 additions & 0 deletions packages/xstate-graph/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
"license": "MIT",
"main": "dist/xstate-graph.cjs.js",
"module": "dist/xstate-graph.esm.js",
"exports": {
".": {
"module": "./dist/xstate-graph.esm.js",
"default": "./dist/xstate-graph.cjs.js"
},
"./package.json": "./package.json"
},
"sideEffects": false,
"files": [
"dist"
Expand Down
7 changes: 7 additions & 0 deletions packages/xstate-immer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@
"license": "MIT",
"main": "dist/xstate-immer.cjs.js",
"module": "dist/xstate-immer.esm.js",
"exports": {
".": {
"module": "./dist/xstate-immer.esm.js",
"default": "./dist/xstate-immer.cjs.js"
},
"./package.json": "./package.json"
},
"sideEffects": false,
"files": [
"dist"
Expand Down
7 changes: 7 additions & 0 deletions packages/xstate-inspect/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@
"license": "MIT",
"main": "dist/xstate-inspect.cjs.js",
"module": "dist/xstate-inspect.esm.js",
"exports": {
".": {
"module": "./dist/xstate-inspect.esm.js",
"default": "./dist/xstate-inspect.cjs.js"
},
"./package.json": "./package.json"
},
"sideEffects": false,
"files": [
"dist"
Expand Down
11 changes: 11 additions & 0 deletions packages/xstate-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@
"license": "MIT",
"main": "dist/xstate-react.cjs.js",
"module": "dist/xstate-react.esm.js",
"exports": {
"./fsm": {
"module": "./fsm/dist/xstate-react-fsm.esm.js",
"default": "./fsm/dist/xstate-react-fsm.cjs.js"
},
".": {
"module": "./dist/xstate-react.esm.js",
"default": "./dist/xstate-react.cjs.js"
},
"./package.json": "./package.json"
},
"types": "dist/xstate-react.cjs.d.ts",
"sideEffects": false,
"files": [
Expand Down
7 changes: 7 additions & 0 deletions packages/xstate-scxml/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
"license": "MIT",
"main": "dist/xstate-scxml.cjs.js",
"module": "dist/xstate-scxml.esm.js",
"exports": {
".": {
"module": "./dist/xstate-scxml.esm.js",
"default": "./dist/xstate-scxml.cjs.js"
},
"./package.json": "./package.json"
},
"sideEffects": false,
"files": [
"dist"
Expand Down
11 changes: 11 additions & 0 deletions packages/xstate-svelte/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@
"license": "MIT",
"main": "dist/xstate-svelte.cjs.js",
"module": "dist/xstate-svelte.esm.js",
"exports": {
"./fsm": {
"module": "./fsm/dist/xstate-svelte-fsm.esm.js",
"default": "./fsm/dist/xstate-svelte-fsm.cjs.js"
},
".": {
"module": "./dist/xstate-svelte.esm.js",
"default": "./dist/xstate-svelte.cjs.js"
},
"./package.json": "./package.json"
},
"sideEffects": false,
"files": [
"dist",
Expand Down
18 changes: 17 additions & 1 deletion packages/xstate-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,18 @@
"main": "dist/xstate-test.cjs.js",
"module": "dist/xstate-test.esm.js",
"browser": {
"./dist/xstate-test.cjs.js": "./dist/xstate-test.browser.cjs.js",
"./dist/xstate-test.esm.js": "./dist/xstate-test.browser.esm.js"
},
"exports": {
".": {
"module": {
"browser": "./dist/xstate-test.browser.esm.js",
"default": "./dist/xstate-test.esm.js"
},
"default": "./dist/xstate-test.cjs.js"
},
"./package.json": "./package.json"
},
"sideEffects": false,
"files": [
"dist"
Expand All @@ -43,5 +52,12 @@
},
"dependencies": {
"@xstate/graph": "^2.0.0-alpha.0"
},
"preconstruct": {
"exports": {
"envConditions": [
"browser"
]
}
}
}
11 changes: 11 additions & 0 deletions packages/xstate-vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@
"license": "MIT",
"main": "dist/xstate-vue.cjs.js",
"module": "dist/xstate-vue.esm.js",
"exports": {
"./fsm": {
"module": "./fsm/dist/xstate-vue-fsm.esm.js",
"default": "./fsm/dist/xstate-vue-fsm.cjs.js"
},
".": {
"module": "./dist/xstate-vue.esm.js",
"default": "./dist/xstate-vue.cjs.js"
},
"./package.json": "./package.json"
},
"sideEffects": false,
"files": [
"dist",
Expand Down
46 changes: 36 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2039,10 +2039,10 @@
"@nodelib/fs.scandir" "2.1.4"
fastq "^1.6.0"

"@preconstruct/cli@^2.1.5":
version "2.1.5"
resolved "https://registry.yarnpkg.com/@preconstruct/cli/-/cli-2.1.5.tgz#f7f6d06809f382521589af15f67b87009b240c58"
integrity sha512-bMnGTkaotxq+xoOkXoUOfTFvxBX/ZUxukcacf3mx3G7Iz5m/T4ZGzSOU12pxl64e+rVWGTKlUsgaDSgyFkup0A==
"@preconstruct/cli@^2.2.2":
version "2.2.2"
resolved "https://registry.yarnpkg.com/@preconstruct/cli/-/cli-2.2.2.tgz#2327aa2486f7c3650cfa726e667a9d80007e50d8"
integrity sha512-7Zk8g/G+SPusoL1Ir3oslj19QDoFuAKeQO8B6fnNkRRgvIntxnylGZyC4wdKVX/eeDHwca1LNLT/GyjXx1f1nA==
dependencies:
"@babel/code-frame" "^7.5.5"
"@babel/core" "^7.7.7"
Expand All @@ -2052,7 +2052,7 @@
"@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 @@ -2119,17 +2119,17 @@
dependencies:
"@rollup/pluginutils" "^3.0.8"

"@rollup/plugin-node-resolve@^9.0.0":
version "9.0.0"
resolved "https://registry.yarnpkg.com/@rollup/plugin-node-resolve/-/plugin-node-resolve-9.0.0.tgz#39bd0034ce9126b39c1699695f440b4b7d2b62e6"
integrity sha512-gPz+utFHLRrd41WMP13Jq5mqqzHL3OXrfj3/MkSyB6UBIcuNt9j60GCbarzMzdf1VHFpOxfQh/ez7wyadLMqkg==
"@rollup/plugin-node-resolve@^11.2.1":
version "11.2.1"
resolved "https://registry.yarnpkg.com/@rollup/plugin-node-resolve/-/plugin-node-resolve-11.2.1.tgz#82aa59397a29cd4e13248b106e6a4a1880362a60"
integrity sha512-yc2n43jcqVyGE2sqV5/YCmocy9ArjVAP/BeXyTtADTBBX6V0e5UMqwO8CdQ0kzjb6zu5P1qMzsScCMRvE9OlVg==
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"

"@rollup/plugin-replace@^2.4.1":
version "2.4.2"
Expand Down Expand Up @@ -5478,6 +5478,13 @@ is-core-module@^2.2.0:
dependencies:
has "^1.0.3"

is-core-module@^2.9.0:
version "2.11.0"
resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.11.0.tgz#ad4cb3e3863e814523c96f3f58d26cc570ff0144"
integrity sha512-RRjxlvLDkD1YJwDbroBHMb+cukurkDWNyHx7D3oNB5x9rb5ogcksMC5wHCadcXoo67gVr/+3GFySh3134zi6rw==
dependencies:
has "^1.0.3"

is-data-descriptor@^0.1.4:
version "0.1.4"
resolved "https://registry.yarnpkg.com/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz#0b5ee648388e2c860282e793f1856fec3f301b56"
Expand Down Expand Up @@ -7846,6 +7853,11 @@ path-parse@^1.0.6:
resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c"
integrity sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==

path-parse@^1.0.7:
version "1.0.7"
resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735"
integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==

path-root-regex@^0.1.0:
version "0.1.2"
resolved "https://registry.yarnpkg.com/path-root-regex/-/path-root-regex-0.1.2.tgz#bfccdc8df5b12dc52c8b43ec38d18d72c04ba96d"
Expand Down Expand Up @@ -8522,6 +8534,15 @@ resolve@^1.14.2:
is-core-module "^2.2.0"
path-parse "^1.0.6"

resolve@^1.19.0:
version "1.22.1"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.22.1.tgz#27cb2ebb53f91abb49470a928bba7558066ac177"
integrity sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw==
dependencies:
is-core-module "^2.9.0"
path-parse "^1.0.7"
supports-preserve-symlinks-flag "^1.0.0"

responselike@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/responselike/-/responselike-1.0.2.tgz#918720ef3b631c5642be068f15ade5a46f4ba1e7"
Expand Down Expand Up @@ -9225,6 +9246,11 @@ supports-hyperlinks@^2.0.0:
has-flag "^4.0.0"
supports-color "^7.0.0"

supports-preserve-symlinks-flag@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09"
integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==

svelte-check@^2.4.5:
version "2.4.5"
resolved "https://registry.yarnpkg.com/svelte-check/-/svelte-check-2.4.5.tgz#a2001993034d495118980bd95577fb3e7980661a"
Expand Down

0 comments on commit 5fb3c68

Please sign in to comment.