From cb658b40a3e333cace7e9eb9a594d50fb39d1165 Mon Sep 17 00:00:00 2001 From: Neko Ayaka Date: Wed, 11 Jun 2025 01:07:48 +0800 Subject: [PATCH] feat(workspace): use tsdown for TypeScript only module --- cspell.config.yaml | 3 + package.json | 1 + packages/ccc/package.json | 9 +- packages/ccc/tsdown.config.ts | 9 ++ packages/server-sdk/package.json | 14 +-- packages/server-sdk/tsdown.config.ts | 10 +++ packages/server-shared/package.json | 18 ++-- packages/server-shared/src/index.ts | 1 + packages/server-shared/tsdown.config.ts | 9 ++ pnpm-lock.yaml | 112 ++++++++++++++++++++---- 10 files changed, 149 insertions(+), 37 deletions(-) create mode 100644 packages/ccc/tsdown.config.ts create mode 100644 packages/server-sdk/tsdown.config.ts create mode 100644 packages/server-shared/tsdown.config.ts diff --git a/cspell.config.yaml b/cspell.config.yaml index 61ef102f7..f505f59a5 100644 --- a/cspell.config.yaml +++ b/cspell.config.yaml @@ -14,6 +14,7 @@ words: - APNG - astrojs - Attributify + - attw - audioworklet - awilix - Ayaka @@ -28,6 +29,7 @@ words: - changelogithub - cientos - cjkfonts + - clippy - collectblock - composables - cooldown @@ -171,6 +173,7 @@ words: - taze - tolist - tresjs + - tsdown - unhead - unocss - unplugin diff --git a/package.json b/package.json index 0e358bfdf..ffca34a6e 100644 --- a/package.json +++ b/package.json @@ -41,6 +41,7 @@ "devDependencies": { "@antfu/eslint-config": "^4.13.3", "@antfu/ni": "^25.0.0", + "@arethetypeswrong/core": "^0.18.2", "@iconify/utils": "^2.3.0", "@types/node": "^22.15.29", "@unocss/eslint-config": "^66.1.3", diff --git a/packages/ccc/package.json b/packages/ccc/package.json index 5e29d5b18..0dee07053 100644 --- a/packages/ccc/package.json +++ b/packages/ccc/package.json @@ -5,17 +5,18 @@ "exports": { ".": { "types": "./dist/index.d.ts", - "default": "./dist/index.mjs" + "default": "./dist/index.js" } }, - "module": "./dist/index.mjs", + "module": "./dist/index.js", "types": "./dist/index.d.ts", "files": [ "dist" ], "scripts": { - "stub": "unbuild --stub", - "build": "unbuild", + "dev": "pnpm run build", + "stub": "pnpm run build", + "build": "tsdown", "test": "vitest run", "test:watch": "vitest", "lint": "eslint .", diff --git a/packages/ccc/tsdown.config.ts b/packages/ccc/tsdown.config.ts new file mode 100644 index 000000000..0e0c750c8 --- /dev/null +++ b/packages/ccc/tsdown.config.ts @@ -0,0 +1,9 @@ +import { defineConfig } from 'tsdown' + +export default defineConfig({ + entry: [ + './src/index.ts', + ], + sourcemap: true, + unused: true, +}) diff --git a/packages/server-sdk/package.json b/packages/server-sdk/package.json index 50549f571..7b360cf22 100644 --- a/packages/server-sdk/package.json +++ b/packages/server-sdk/package.json @@ -17,13 +17,13 @@ "exports": { ".": { "types": "./dist/index.d.ts", - "import": "./dist/index.mjs", - "require": "./dist/index.cjs" + "import": "./dist/index.js", + "require": "./dist/index.js" }, "./utils/node": { "types": "./dist/utils/node/index.d.ts", - "import": "./dist/utils/node/index.mjs", - "require": "./dist/utils/node/index.cjs" + "import": "./dist/utils/node/index.js", + "require": "./dist/utils/node/index.js" } }, "main": "./dist/index.cjs", @@ -35,9 +35,9 @@ "package.json" ], "scripts": { - "dev": "pnpm run stub", - "stub": "unbuild --stub", - "build": "unbuild", + "dev": "pnpm run build", + "stub": "pnpm run build", + "build": "tsdown", "typecheck": "tsc --noEmit" }, "dependencies": { diff --git a/packages/server-sdk/tsdown.config.ts b/packages/server-sdk/tsdown.config.ts new file mode 100644 index 000000000..adf46c50f --- /dev/null +++ b/packages/server-sdk/tsdown.config.ts @@ -0,0 +1,10 @@ +import { defineConfig } from 'tsdown' + +export default defineConfig({ + entry: [ + './src/index.ts', + './src/utils/node/index.ts', + ], + sourcemap: true, + unused: true, +}) diff --git a/packages/server-shared/package.json b/packages/server-shared/package.json index 932e0a445..fa6605e20 100644 --- a/packages/server-shared/package.json +++ b/packages/server-shared/package.json @@ -17,12 +17,13 @@ "exports": { "./types": { "types": "./dist/types/index.d.ts", - "import": "./dist/types/index.mjs", - "require": "./dist/types/index.cjs" + "import": "./dist/types/index.js", + "require": "./dist/types/index.js", + "default": "./dist/types/index.js" } }, - "main": "./dist/types/index.cjs", - "module": "./dist/types/index.mjs", + "main": "./dist/types/index.js", + "module": "./dist/types/index.js", "types": "./dist/types/index.d.ts", "files": [ "README.md", @@ -30,12 +31,9 @@ "package.json" ], "scripts": { - "dev": "pnpm run stub", - "stub": "unbuild --stub", - "build": "unbuild", + "dev": "pnpm run build", + "stub": "pnpm run build", + "build": "tsdown", "typecheck": "tsc --noEmit" - }, - "dependencies": { - "crossws": "^0.4.1" } } diff --git a/packages/server-shared/src/index.ts b/packages/server-shared/src/index.ts index e69de29bb..4a6af3ebd 100644 --- a/packages/server-shared/src/index.ts +++ b/packages/server-shared/src/index.ts @@ -0,0 +1 @@ +console.warn('import @proj-airi/server-shared/types instead') diff --git a/packages/server-shared/tsdown.config.ts b/packages/server-shared/tsdown.config.ts new file mode 100644 index 000000000..68a53b3b0 --- /dev/null +++ b/packages/server-shared/tsdown.config.ts @@ -0,0 +1,9 @@ +import { defineConfig } from 'tsdown' + +export default defineConfig({ + entry: [ + './src/', + ], + sourcemap: true, + unused: true, +}) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ec82ef90b..d27258307 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -69,6 +69,9 @@ importers: '@antfu/ni': specifier: ^25.0.0 version: 25.0.0 + '@arethetypeswrong/core': + specifier: ^0.18.2 + version: 0.18.2 '@iconify/utils': specifier: ^2.3.0 version: 2.3.0 @@ -113,7 +116,7 @@ importers: version: 19.1.0 tsdown: specifier: ^0.12.7 - version: 0.12.7(typescript@5.8.3)(vue-tsc@2.2.10(typescript@5.8.3)) + version: 0.12.7(@arethetypeswrong/core@0.18.2)(typescript@5.8.3)(unplugin-unused@0.5.1)(vue-tsc@2.2.10(typescript@5.8.3)) typescript: specifier: ~5.8.3 version: 5.8.3 @@ -855,11 +858,7 @@ importers: specifier: ^6.1.4 version: 6.1.4 - packages/server-shared: - dependencies: - crossws: - specifier: ^0.4.1 - version: 0.4.1 + packages/server-shared: {} packages/stage-ui: dependencies: @@ -1455,6 +1454,9 @@ packages: resolution: {integrity: sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw==} engines: {node: '>=6.0.0'} + '@andrewbranch/untar.js@1.0.3': + resolution: {integrity: sha512-Jh15/qVmrLGhkKJBdXlK1+9tY4lZruYjsgkDFj08ZmDiWVBLJcqkok7Z0/R0In+i1rScBpJlSvrTS2Lm41Pbnw==} + '@antfu/eslint-config@4.13.3': resolution: {integrity: sha512-jo3tjyZoRSPTuSwcaHRbPHaHYvrFosPj0ySLL2jFBCjK9wvo9w1fasKqLRMnc/qCKCMDGCH0egheJV801lJgiA==} hasBin: true @@ -1530,6 +1532,10 @@ packages: peerDependencies: ajv: '>=8' + '@arethetypeswrong/core@0.18.2': + resolution: {integrity: sha512-GiwTmBFOU1/+UVNqqCGzFJYfBXEytUkiI+iRZ6Qx7KmUVtLm00sYySkfe203C9QtPG11yOz1ZaMek8dT/xnlgg==} + engines: {node: '>=20'} + '@astrojs/compiler@2.11.0': resolution: {integrity: sha512-zZOO7i+JhojO8qmlyR/URui6LyfHJY6m+L9nwyX5GiKD78YoRaZ5tzz6X0fkl+5bD3uwlDHayf6Oe8Fu36RKNg==} @@ -2124,6 +2130,9 @@ packages: resolution: {integrity: sha512-6zABk/ECA/QYSCQ1NGiVwwbQerUCZ+TQbp64Q3AgmfNvurHH0j8TtXa1qbShXA6qqkpAj4V5W8pP6mLe1mcMqA==} engines: {node: '>=18'} + '@braidai/lang@1.1.1': + resolution: {integrity: sha512-5uM+no3i3DafVgkoW7ayPhEGHNNBZCSj5TrGDQt0ayEKQda5f3lAXlmQg0MR5E0gKgmTzUUEtSWHsEC3h9jUcg==} + '@browserbasehq/sdk@2.5.0': resolution: {integrity: sha512-bcnbYZvm5Ht1nrHUfWDK4crspiTy1ESJYMApsMiOTUnlKOan0ocRD6m7hZH34iSC2c2XWsoryR80cwsYgCBWzQ==} @@ -3345,6 +3354,9 @@ packages: '@lezer/lr@1.4.2': resolution: {integrity: sha512-pu0K1jCIdnQ12aWNaAVU5bzi7Bd1w54J3ECgANPmYLtQKP0HBj2cE/5coBD66MT10xbtIuUr7tg0Shbsvk0mDA==} + '@loaderkit/resolve@1.0.4': + resolution: {integrity: sha512-rJzYKVcV4dxJv+vW6jlvagF8zvGxHJ2+HTr1e2qOejfmGhAApgJHl8Aog4mMszxceTRiKTTbnpgmTO1bEZHV/A==} + '@marijn/find-cluster-break@1.0.2': resolution: {integrity: sha512-l0h88YhZFyKdXIFNfSWpyjStDjGHwZ/U7iobcK1cQQD8sejsONdQtTVU+1wVN1PBw40PiiHB1vA5S7VTfQiP9g==} @@ -6064,6 +6076,9 @@ packages: citty@0.1.6: resolution: {integrity: sha512-tskPPKEs8D2KPafUypv2gxwJP8h/OaJmC82QQGGDQcHvXX43xF2VDACcJVmZ0EuSxkpO9Kc4MlrA3q0+FG58AQ==} + cjs-module-lexer@1.4.3: + resolution: {integrity: sha512-9z8TZaGM1pfswYeXrUpzPrkx8UnWYdhJclsiYMm6x/w5+nN+8Tf/LnAgfLGQCm59qAOxU8WwHEq2vNwF6i4j+Q==} + clean-regexp@1.0.0: resolution: {integrity: sha512-GfisEZEJvzKrmGWkvfhgzcz/BllN1USeqD2V6tg14OAOgaCD2Z/PUEuxnAZ/nPvmaHRG7a8y77p1T/IRQ4D1Hw==} engines: {node: '>=4'} @@ -8356,6 +8371,10 @@ packages: lru-cache@10.4.3: resolution: {integrity: sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==} + lru-cache@11.1.0: + resolution: {integrity: sha512-QIXZUBJUx+2zHUdQujWejBkcD9+cs94tLn0+YL8UrCh+D5sCXZ4c7LaEH48pNwRY3MLDgqUFyhlCyjJPf1WP0A==} + engines: {node: 20 || >=22} + lru-cache@5.1.1: resolution: {integrity: sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==} @@ -10904,6 +10923,11 @@ packages: engines: {node: '>=4.2.0'} hasBin: true + typescript@5.6.1-rc: + resolution: {integrity: sha512-E3b2+1zEFu84jB0YQi9BORDjz9+jGbwwy1Zi3G0LUNw7a7cePUrHMRNy8aPh53nXpkFGVHSxIZo5vKTfYaFiBQ==} + engines: {node: '>=14.17'} + hasBin: true + typescript@5.8.3: resolution: {integrity: sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==} engines: {node: '>=14.17'} @@ -11099,6 +11123,10 @@ packages: webpack: optional: true + unplugin-unused@0.5.1: + resolution: {integrity: sha512-USnsy4XsInQFcIb/kSt5HbTkwIIYfW1ujGN0jPanq76IvG7RsqHPk4kJqDoZSqCgDkTjolr72a/f7K1Hr2XmWg==} + engines: {node: '>=20.18.0'} + unplugin-utils@0.2.4: resolution: {integrity: sha512-8U/MtpkPkkk3Atewj1+RcKIjb5WBimZ/WSLhhR3w6SsIj8XJuKTacSP8g+2JhfSGw0Cb125Y+2zA/IzJZDVbhA==} engines: {node: '>=18.12.0'} @@ -11129,6 +11157,10 @@ packages: resolution: {integrity: sha512-3n7YA46rROb3zSj8fFxtxC/PqoyvYQ0llwz9wtUPUutr9ig09C8gGo5CWCwHrUzlqC1LLR43kxp5vEIyH1ac1w==} engines: {node: '>=18.12.0'} + unplugin@2.3.5: + resolution: {integrity: sha512-RyWSb5AHmGtjjNQ6gIlA67sHOsWpsbWpwDokLwTcejVdOjEkJZh7QKu14J00gDDVSh8kGH4KYC/TNBceXFZhtw==} + engines: {node: '>=18.12.0'} + unrs-resolver@1.7.9: resolution: {integrity: sha512-hhFtY782YKwpz54G1db49YYS1RuMn8mBylIrCldrjb9BxZKnQ2xHw7+2zcl7H6fnUlTHGWv23/+677cpufhfxQ==} @@ -11271,6 +11303,10 @@ packages: typescript: optional: true + validate-npm-package-name@5.0.1: + resolution: {integrity: sha512-OljLrQ9SQdOUqTaQxqL5dEfZWrXExyyWsozYlAWFawPVNuD83igl7uJD2RTkNMbniIYgt8l81eCJGIdQF7avLQ==} + engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} + vary@1.1.2: resolution: {integrity: sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==} engines: {node: '>= 0.8'} @@ -12025,6 +12061,8 @@ snapshots: '@jridgewell/gen-mapping': 0.3.5 '@jridgewell/trace-mapping': 0.3.25 + '@andrewbranch/untar.js@1.0.3': {} + '@antfu/eslint-config@4.13.3(@typescript-eslint/utils@8.33.1(eslint@9.28.0(jiti@2.4.2))(typescript@5.8.3))(@unocss/eslint-plugin@66.1.3(eslint@9.28.0(jiti@2.4.2))(typescript@5.8.3))(@vue/compiler-sfc@3.5.16)(eslint-import-resolver-node@0.3.9)(eslint-plugin-format@1.0.1(eslint@9.28.0(jiti@2.4.2)))(eslint@9.28.0(jiti@2.4.2))(typescript@5.8.3)(vitest@3.2.1(@types/debug@4.1.12)(@types/node@22.15.29)(jiti@2.4.2)(jsdom@25.0.1(bufferutil@4.0.9)(utf-8-validate@5.0.10))(less@4.3.0)(msw@2.7.3(@types/node@22.15.29)(typescript@5.8.3))(terser@5.17.6)(tsx@4.19.4)(yaml@2.8.0))': dependencies: '@antfu/install-pkg': 1.1.0 @@ -12118,6 +12156,17 @@ snapshots: jsonpointer: 5.0.1 leven: 3.1.0 + '@arethetypeswrong/core@0.18.2': + dependencies: + '@andrewbranch/untar.js': 1.0.3 + '@loaderkit/resolve': 1.0.4 + cjs-module-lexer: 1.4.3 + fflate: 0.8.2 + lru-cache: 11.1.0 + semver: 7.7.2 + typescript: 5.6.1-rc + validate-npm-package-name: 5.0.1 + '@astrojs/compiler@2.11.0': {} '@astrojs/internal-helpers@0.6.1': {} @@ -12311,7 +12360,7 @@ snapshots: '@babel/helper-builder-binary-assignment-operator-visitor@7.25.9': dependencies: '@babel/traverse': 7.25.9 - '@babel/types': 7.27.3 + '@babel/types': 7.27.6 transitivePeerDependencies: - supports-color @@ -12404,7 +12453,7 @@ snapshots: '@babel/helper-simple-access@7.25.9': dependencies: '@babel/traverse': 7.25.9 - '@babel/types': 7.27.3 + '@babel/types': 7.27.6 transitivePeerDependencies: - supports-color @@ -12429,7 +12478,7 @@ snapshots: dependencies: '@babel/template': 7.25.9 '@babel/traverse': 7.25.9 - '@babel/types': 7.27.3 + '@babel/types': 7.27.6 transitivePeerDependencies: - supports-color @@ -12940,7 +12989,7 @@ snapshots: dependencies: '@babel/core': 7.26.0 '@babel/helper-plugin-utils': 7.25.9 - '@babel/types': 7.27.3 + '@babel/types': 7.27.6 esutils: 2.0.3 '@babel/runtime@7.26.7': @@ -12980,6 +13029,8 @@ snapshots: '@bcoe/v8-coverage@1.0.2': {} + '@braidai/lang@1.1.1': {} + '@browserbasehq/sdk@2.5.0(encoding@0.1.13)': dependencies: '@types/node': 18.19.80 @@ -14201,6 +14252,10 @@ snapshots: dependencies: '@lezer/common': 1.2.3 + '@loaderkit/resolve@1.0.4': + dependencies: + '@braidai/lang': 1.1.1 + '@marijn/find-cluster-break@1.0.2': {} '@mdx-js/mdx@3.1.0(acorn@8.14.1)': @@ -15405,7 +15460,7 @@ snapshots: '@types/babel__core@7.20.5': dependencies: '@babel/parser': 7.27.5 - '@babel/types': 7.27.3 + '@babel/types': 7.27.6 '@types/babel__generator': 7.6.8 '@types/babel__template': 7.4.4 '@types/babel__traverse': 7.20.6 @@ -15413,18 +15468,18 @@ snapshots: '@types/babel__generator@7.6.8': dependencies: - '@babel/types': 7.27.3 + '@babel/types': 7.27.6 optional: true '@types/babel__template@7.4.4': dependencies: '@babel/parser': 7.27.5 - '@babel/types': 7.27.3 + '@babel/types': 7.27.6 optional: true '@types/babel__traverse@7.20.6': dependencies: - '@babel/types': 7.27.3 + '@babel/types': 7.27.6 optional: true '@types/chai@5.2.2': @@ -17553,6 +17608,8 @@ snapshots: dependencies: consola: 3.4.2 + cjs-module-lexer@1.4.3: {} + clean-regexp@1.0.0: dependencies: escape-string-regexp: 1.0.5 @@ -20269,6 +20326,8 @@ snapshots: lru-cache@10.4.3: {} + lru-cache@11.1.0: {} + lru-cache@5.1.1: dependencies: yallist: 3.1.1 @@ -23517,7 +23576,7 @@ snapshots: optionalDependencies: typescript: 5.8.3 - tsdown@0.12.7(typescript@5.8.3)(vue-tsc@2.2.10(typescript@5.8.3)): + tsdown@0.12.7(@arethetypeswrong/core@0.18.2)(typescript@5.8.3)(unplugin-unused@0.5.1)(vue-tsc@2.2.10(typescript@5.8.3)): dependencies: ansis: 4.1.0 cac: 6.7.14 @@ -23533,7 +23592,9 @@ snapshots: tinyglobby: 0.2.14 unconfig: 7.3.2 optionalDependencies: + '@arethetypeswrong/core': 0.18.2 typescript: 5.8.3 + unplugin-unused: 0.5.1 transitivePeerDependencies: - '@typescript/native-preview' - oxc-resolver @@ -23592,6 +23653,8 @@ snapshots: typescript@3.9.10: {} + typescript@5.6.1-rc: {} + typescript@5.8.3: {} typical@4.0.0: {} @@ -23654,7 +23717,7 @@ snapshots: acorn: 8.14.1 estree-walker: 3.0.3 magic-string: 0.30.17 - unplugin: 2.3.2 + unplugin: 2.3.5 optional: true undici-types@5.26.5: {} @@ -23863,6 +23926,14 @@ snapshots: unplugin: 1.16.1 vite: 6.3.5(@types/node@22.15.29)(jiti@2.4.2)(less@4.3.0)(terser@5.17.6)(tsx@4.19.4)(yaml@2.8.0) + unplugin-unused@0.5.1: + dependencies: + js-tokens: 9.0.1 + picocolors: 1.1.1 + pkg-types: 2.1.0 + unplugin: 2.3.5 + optional: true + unplugin-utils@0.2.4: dependencies: pathe: 2.0.3 @@ -24001,6 +24072,13 @@ snapshots: picomatch: 4.0.2 webpack-virtual-modules: 0.6.2 + unplugin@2.3.5: + dependencies: + acorn: 8.14.1 + picomatch: 4.0.2 + webpack-virtual-modules: 0.6.2 + optional: true + unrs-resolver@1.7.9: dependencies: napi-postinstall: 0.2.3 @@ -24121,6 +24199,8 @@ snapshots: optionalDependencies: typescript: 5.8.3 + validate-npm-package-name@5.0.1: {} + vary@1.1.2: {} vaul-vue@0.4.1(reka-ui@2.3.0(typescript@5.8.3)(vue@3.5.16(typescript@5.8.3)))(vue@3.5.16(typescript@5.8.3)):