From b157f292a3e82d58a54fa4c16ea9fa891c925165 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Wed, 15 Nov 2023 12:06:03 +0100 Subject: [PATCH] Move exports related to Sky to a separate entrypoint in `machine-extractor` package (#402) * Move exports related to Sky to a separate entrypoint in `machine-extractor` package * add changeset * run tests after build --- .changeset/tidy-tigers-kiss.md | 5 ++++ .github/workflows/ci.yml | 2 +- apps/cli/src/sky/writeConfigToFiles.ts | 2 +- package.json | 10 ++++++-- packages/machine-extractor/package.json | 28 +++++++++++++++++++++ packages/machine-extractor/sky/package.json | 4 +++ packages/machine-extractor/src/index.ts | 3 --- packages/machine-extractor/src/sky/index.ts | 3 +++ packages/shared/forEachAction/package.json | 3 ++- packages/shared/package.json | 22 ++++++++++++++++ yarn.lock | 14 ++++++++--- 11 files changed, 84 insertions(+), 12 deletions(-) create mode 100644 .changeset/tidy-tigers-kiss.md create mode 100644 packages/machine-extractor/sky/package.json create mode 100644 packages/machine-extractor/src/sky/index.ts diff --git a/.changeset/tidy-tigers-kiss.md b/.changeset/tidy-tigers-kiss.md new file mode 100644 index 00000000..5d1a4565 --- /dev/null +++ b/.changeset/tidy-tigers-kiss.md @@ -0,0 +1,5 @@ +--- +'@xstate/machine-extractor': patch +--- + +Moved exports related to Sky to a separate entrypoint. diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1c07782b..35a1e49a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,10 +15,10 @@ jobs: cache: 'yarn' - run: yarn - - run: yarn turbo run lint test - run: yarn deps:build - run: yarn turbo run build - run: yarn vscode:dev + - run: yarn turbo run lint test - run: (cd apps/extension/client && npx vsce package --yarn) - uses: actions/upload-artifact@v3 with: diff --git a/apps/cli/src/sky/writeConfigToFiles.ts b/apps/cli/src/sky/writeConfigToFiles.ts index 24e19060..6ddc8db9 100644 --- a/apps/cli/src/sky/writeConfigToFiles.ts +++ b/apps/cli/src/sky/writeConfigToFiles.ts @@ -2,7 +2,7 @@ import { SkyConfig } from '@statelyai/sky'; import { modifySkyConfigSource, skyConfigExtractFromFile, -} from '@xstate/machine-extractor'; +} from '@xstate/machine-extractor/sky'; import 'dotenv/config'; import * as fs from 'fs/promises'; import fetch from 'isomorphic-fetch'; diff --git a/package.json b/package.json index 3dbc54fe..0b56aeeb 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,13 @@ "preconstruct": { "packages": [ "packages/*" - ] + ], + "exports": { + "importConditionDefaultExport": "default" + }, + "___experimentalFlags_WILL_CHANGE_IN_PATCH": { + "importsConditions": true + } }, "turbo": { "globalDependencies": [ @@ -80,7 +86,7 @@ "@changesets/changelog-github": "^0.4.3", "@changesets/cli": "^2.21.0", "@manypkg/cli": "^0.19.1", - "@preconstruct/cli": "^2.5.0", + "@preconstruct/cli": "^2.8.1", "@types/node": "^16.0.1", "@typescript-eslint/eslint-plugin": "^5.59.0", "@typescript-eslint/parser": "^5.59.0", diff --git a/packages/machine-extractor/package.json b/packages/machine-extractor/package.json index a612c551..f2b39063 100644 --- a/packages/machine-extractor/package.json +++ b/packages/machine-extractor/package.json @@ -2,6 +2,28 @@ "name": "@xstate/machine-extractor", "version": "0.12.1", "main": "dist/xstate-machine-extractor.cjs.js", + "module": "dist/xstate-machine-extractor.esm.js", + "exports": { + ".": { + "types": { + "import": "./dist/xstate-machine-extractor.cjs.mjs", + "default": "./dist/xstate-machine-extractor.cjs.js" + }, + "module": "./dist/xstate-machine-extractor.esm.js", + "import": "./dist/xstate-machine-extractor.cjs.mjs", + "default": "./dist/xstate-machine-extractor.cjs.js" + }, + "./sky": { + "types": { + "import": "./sky/dist/xstate-machine-extractor-sky.cjs.mjs", + "default": "./sky/dist/xstate-machine-extractor-sky.cjs.js" + }, + "module": "./sky/dist/xstate-machine-extractor-sky.esm.js", + "import": "./sky/dist/xstate-machine-extractor-sky.cjs.mjs", + "default": "./sky/dist/xstate-machine-extractor-sky.cjs.js" + }, + "./package.json": "./package.json" + }, "author": "Matt Pocock", "license": "MIT", "scripts": { @@ -30,5 +52,11 @@ "patch-package": "^6.4.7", "typescript": "^5.0.4", "xstate": "^4.33.4" + }, + "preconstruct": { + "entrypoints": [ + "index.ts", + "sky/index.ts" + ] } } diff --git a/packages/machine-extractor/sky/package.json b/packages/machine-extractor/sky/package.json new file mode 100644 index 00000000..bab61df4 --- /dev/null +++ b/packages/machine-extractor/sky/package.json @@ -0,0 +1,4 @@ +{ + "main": "dist/xstate-machine-extractor-sky.cjs.js", + "module": "dist/xstate-machine-extractor-sky.esm.js" +} diff --git a/packages/machine-extractor/src/index.ts b/packages/machine-extractor/src/index.ts index ed89b3d2..e1dc2a1d 100644 --- a/packages/machine-extractor/src/index.ts +++ b/packages/machine-extractor/src/index.ts @@ -5,9 +5,6 @@ export * from './extractMachinesFromFile'; export * from './getMachineExtractResult'; export * from './getMachineNodesFromFile'; export * from './groupByUniqueName'; -export * from './sky/skyConfigExtractFromFile'; -export * from './sky/skyConfigModifySource'; -export * from './sky/skyConfigUtils'; export * from './stateNode'; export * from './types'; export * from './utils'; diff --git a/packages/machine-extractor/src/sky/index.ts b/packages/machine-extractor/src/sky/index.ts new file mode 100644 index 00000000..db58116e --- /dev/null +++ b/packages/machine-extractor/src/sky/index.ts @@ -0,0 +1,3 @@ +export * from './skyConfigExtractFromFile'; +export * from './skyConfigModifySource'; +export * from './skyConfigUtils'; diff --git a/packages/shared/forEachAction/package.json b/packages/shared/forEachAction/package.json index 1f79209b..b78bcec3 100644 --- a/packages/shared/forEachAction/package.json +++ b/packages/shared/forEachAction/package.json @@ -1,3 +1,4 @@ { - "main": "dist/xstate-tools-shared-forEachAction.cjs.js" + "main": "dist/xstate-tools-shared-forEachAction.cjs.js", + "module": "dist/xstate-tools-shared-forEachAction.esm.js" } diff --git a/packages/shared/package.json b/packages/shared/package.json index de02da18..032296b5 100644 --- a/packages/shared/package.json +++ b/packages/shared/package.json @@ -2,6 +2,28 @@ "name": "@xstate/tools-shared", "version": "4.0.3", "main": "dist/xstate-tools-shared.cjs.js", + "module": "dist/xstate-tools-shared.esm.js", + "exports": { + ".": { + "types": { + "import": "./dist/xstate-tools-shared.cjs.mjs", + "default": "./dist/xstate-tools-shared.cjs.js" + }, + "module": "./dist/xstate-tools-shared.esm.js", + "import": "./dist/xstate-tools-shared.cjs.mjs", + "default": "./dist/xstate-tools-shared.cjs.js" + }, + "./forEachAction": { + "types": { + "import": "./forEachAction/dist/xstate-tools-shared-forEachAction.cjs.mjs", + "default": "./forEachAction/dist/xstate-tools-shared-forEachAction.cjs.js" + }, + "module": "./forEachAction/dist/xstate-tools-shared-forEachAction.esm.js", + "import": "./forEachAction/dist/xstate-tools-shared-forEachAction.cjs.mjs", + "default": "./forEachAction/dist/xstate-tools-shared-forEachAction.cjs.js" + }, + "./package.json": "./package.json" + }, "license": "MIT", "dependencies": { "@xstate/machine-extractor": "^0.12.1" diff --git a/yarn.lock b/yarn.lock index 5b12b963..efe6684b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1645,10 +1645,10 @@ "@nodelib/fs.scandir" "2.1.5" fastq "^1.6.0" -"@preconstruct/cli@^2.5.0": - version "2.5.0" - resolved "https://registry.yarnpkg.com/@preconstruct/cli/-/cli-2.5.0.tgz#f66ac50aa9a3f7801efacffc8040fdf9b6d7f483" - integrity sha512-EIpiKdSS2KD3hvSKMftJB8jY36YNYoe1+v2u3UcLY0kutqSpxfh/kBKaYmLvXmBQhBo21ccYARB8itwFLOVKjw== +"@preconstruct/cli@^2.8.1": + version "2.8.1" + resolved "https://registry.yarnpkg.com/@preconstruct/cli/-/cli-2.8.1.tgz#7d7f9fa32e1bfd355d79062a9ccc5af4c97b3915" + integrity sha512-PX5w+au06iY/QaT+9RLmRlIfavRCRoMTC/krwtNrgPEnubR9e6P+QlywrKmwiEvkzbR9AEzGnRZL8uNRDDMzrQ== dependencies: "@babel/code-frame" "^7.5.5" "@babel/core" "^7.7.7" @@ -1687,6 +1687,7 @@ semver "^7.3.4" terser "^5.16.8" v8-compile-cache "^2.1.1" + zod "^3.21.4" "@preconstruct/hook@^0.4.0": version "0.4.0" @@ -7764,3 +7765,8 @@ yocto-queue@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b" integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q== + +zod@^3.21.4: + version "3.22.4" + resolved "https://registry.yarnpkg.com/zod/-/zod-3.22.4.tgz#f31c3a9386f61b1f228af56faa9255e845cf3fff" + integrity sha512-iC+8Io04lddc+mVqQ9AZ7OQ2MrUKGN+oIQyq1vemgt46jwCwLfhq7/pwnBnNXXXZb8VTVLKwp9EDkx+ryxIWmg==