diff --git a/.github/renovate.json5 b/.github/renovate.json5 index 17898db2741284..05c1c02ab4cb12 100644 --- a/.github/renovate.json5 +++ b/.github/renovate.json5 @@ -16,7 +16,6 @@ "esbuild", "rollup", "node", - "ts-node", "typescript", // breaking changes diff --git a/.npmrc b/.npmrc index 0a8182ea5f2c53..10aa0abfa4707b 100644 --- a/.npmrc +++ b/.npmrc @@ -4,3 +4,4 @@ hoist-pattern[]=@emotion/* hoist-pattern[]=postcss hoist-pattern[]=pug hoist-pattern[]=source-map-support +hoist-pattern[]=ts-node diff --git a/package.json b/package.json index dd19523dfdc497..aa8ca679682beb 100644 --- a/package.json +++ b/package.json @@ -28,8 +28,8 @@ "docs-serve": "vitepress serve docs", "build": "pnpm -r --filter=./packages/* run build", "dev": "pnpm -r --parallel --filter=./packages/* run dev", - "release": "ts-node scripts/release.ts", - "ci-publish": "ts-node scripts/publishCI.ts", + "release": "esno scripts/release.ts", + "ci-publish": "esno scripts/publishCI.ts", "ci-docs": "run-s build docs-build" }, "devDependencies": { @@ -63,6 +63,7 @@ "eslint-define-config": "^1.4.0", "eslint-plugin-import": "^2.26.0", "eslint-plugin-node": "^11.1.0", + "esno": "^0.15.0", "execa": "^5.1.1", "fs-extra": "^10.1.0", "kill-port": "^1.6.1", @@ -79,7 +80,6 @@ "semver": "^7.3.7", "simple-git-hooks": "^2.7.0", "sirv": "^2.0.2", - "ts-node": "^10.7.0", "typescript": "^4.6.4", "unbuild": "^0.7.4", "vite": "workspace:*", @@ -89,7 +89,7 @@ }, "simple-git-hooks": { "pre-commit": "pnpm exec lint-staged --concurrent false", - "commit-msg": "pnpm exec ts-node scripts/verifyCommit.ts $1" + "commit-msg": "pnpm exec esno scripts/verifyCommit.ts $1" }, "lint-staged": { "*": [ diff --git a/packages/plugin-legacy/package.json b/packages/plugin-legacy/package.json index 828b31d57ddfe2..e14b02b64c53ba 100644 --- a/packages/plugin-legacy/package.json +++ b/packages/plugin-legacy/package.json @@ -19,7 +19,7 @@ "scripts": { "dev": "unbuild --stub", "build": "unbuild && pnpm run patch-cjs", - "patch-cjs": "ts-node ../../scripts/patchCJS.ts", + "patch-cjs": "esno ../../scripts/patchCJS.ts", "prepublishOnly": "npm run build" }, "engines": { diff --git a/packages/plugin-react/package.json b/packages/plugin-react/package.json index deed747475b175..55a54a3cbcacb6 100644 --- a/packages/plugin-react/package.json +++ b/packages/plugin-react/package.json @@ -23,7 +23,7 @@ "scripts": { "dev": "unbuild --stub", "build": "unbuild && pnpm run patch-cjs", - "patch-cjs": "ts-node ../../scripts/patchCJS.ts", + "patch-cjs": "esno ../../scripts/patchCJS.ts", "prepublishOnly": "npm run build" }, "engines": { diff --git a/packages/plugin-vue-jsx/package.json b/packages/plugin-vue-jsx/package.json index 6dbd11389eab5b..79ee5706f06dfb 100644 --- a/packages/plugin-vue-jsx/package.json +++ b/packages/plugin-vue-jsx/package.json @@ -19,7 +19,7 @@ "scripts": { "dev": "unbuild --stub", "build": "unbuild && pnpm run patch-cjs", - "patch-cjs": "ts-node ../../scripts/patchCJS.ts", + "patch-cjs": "esno ../../scripts/patchCJS.ts", "prepublishOnly": "npm run build" }, "engines": { diff --git a/packages/plugin-vue/package.json b/packages/plugin-vue/package.json index 6a08c1dff70bdc..75f245390628f0 100644 --- a/packages/plugin-vue/package.json +++ b/packages/plugin-vue/package.json @@ -19,7 +19,7 @@ "scripts": { "dev": "unbuild --stub", "build": "unbuild && pnpm run patch-cjs", - "patch-cjs": "ts-node ../../scripts/patchCJS.ts", + "patch-cjs": "esno ../../scripts/patchCJS.ts", "prepublishOnly": "npm run build" }, "engines": { diff --git a/packages/vite/package.json b/packages/vite/package.json index 7fa8f652b56729..7e28c2ae3ea693 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -34,7 +34,7 @@ "build-bundle": "rollup -c", "build-types": "run-s build-temp-types patch-types roll-types", "build-temp-types": "tsc --emitDeclarationOnly --outDir temp/node -p src/node", - "patch-types": "ts-node scripts/patchTypes.ts", + "patch-types": "esno scripts/patchTypes.ts", "roll-types": "api-extractor run && rimraf temp", "lint": "eslint --ext .ts src/**", "format": "prettier --write --parser typescript \"src/**/*.ts\"", diff --git a/packages/vite/scripts/patchTypes.ts b/packages/vite/scripts/patchTypes.ts index ec5ade0224391c..e31f3a39e82325 100644 --- a/packages/vite/scripts/patchTypes.ts +++ b/packages/vite/scripts/patchTypes.ts @@ -1,13 +1,15 @@ +import { readFileSync, readdirSync, statSync, writeFileSync } from 'fs' +import { dirname, relative, resolve } from 'path' +import { fileURLToPath } from 'url' import type { ParseResult } from '@babel/parser' import { parse } from '@babel/parser' import type { File } from '@babel/types' import colors from 'picocolors' -import { readdirSync, readFileSync, statSync, writeFileSync } from 'fs' import MagicString from 'magic-string' -import { dirname, relative, resolve } from 'path' -const tempDir = resolve(__dirname, '../temp/node') -const typesDir = resolve(__dirname, '../types') +const dir = dirname(fileURLToPath(import.meta.url)) +const tempDir = resolve(dir, '../temp/node') +const typesDir = resolve(dir, '../types') // walk through the temp dts dir, find all import/export of types/* // and rewrite them into relative imports - so that api-extractor actually diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b7c68fc69d5fda..358d7df259b4af 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -40,6 +40,7 @@ importers: eslint-define-config: ^1.4.0 eslint-plugin-import: ^2.26.0 eslint-plugin-node: ^11.1.0 + esno: ^0.15.0 execa: ^5.1.1 fs-extra: ^10.1.0 kill-port: ^1.6.1 @@ -56,7 +57,6 @@ importers: semver: ^7.3.7 simple-git-hooks: ^2.7.0 sirv: ^2.0.2 - ts-node: ^10.7.0 typescript: ^4.6.4 unbuild: ^0.7.4 vite: workspace:* @@ -94,6 +94,7 @@ importers: eslint-define-config: 1.4.0 eslint-plugin-import: 2.26.0_doddzorl55y6dbr5ij3nshfl64 eslint-plugin-node: 11.1.0_eslint@8.15.0 + esno: 0.15.0 execa: 5.1.1 fs-extra: 10.1.0 kill-port: 1.6.1 @@ -110,7 +111,6 @@ importers: semver: 7.3.7 simple-git-hooks: 2.7.0 sirv: 2.0.2 - ts-node: 10.7.0_sm5zkxj4s52nbddwl76qwfh6ya typescript: 4.6.4 unbuild: 0.7.4 vite: link:packages/vite @@ -1592,6 +1592,27 @@ packages: resolution: {integrity: sha512-6U71C2Wp7r5XtFtQzYrW5iKFT67OixrSxjI4MptCHzdSVlgabczzqLe0ZSgnub/5Kp4hSbpDB1tMytZY9pwxxA==} dev: false + /@esbuild-kit/cjs-loader/1.0.0: + resolution: {integrity: sha512-6oPhu5QcuTsU5nO3hBCd6OdfeaGsheU6OZrQSAzBsXOiZQ+lB2Zy1bAeAPKqzVGz16kBbheW+OuL54gLD79HdA==} + dependencies: + '@esbuild-kit/core-utils': 1.0.0 + get-tsconfig: 3.0.1 + dev: true + + /@esbuild-kit/core-utils/1.0.0: + resolution: {integrity: sha512-OpBaYYkCxIFnTjk46dYaZplHrLXkYZvw0FporqTEPEWNJV8k2/+LTIZ1U49NdEBB33A3Ke/78KG78EoDnLENcg==} + dependencies: + esbuild: 0.14.38 + dev: true + + /@esbuild-kit/esm-loader/1.0.0: + resolution: {integrity: sha512-fZtvhHmO0fKNHszwb9GtBr4eaBA4ZAPxDpV/oWLh0R45IgMNz7lDIGeqsDHFTwQ4LeFgOMjzRIH0JapX8FUQmQ==} + dependencies: + '@esbuild-kit/core-utils': 1.0.0 + es-module-lexer: 0.10.5 + get-tsconfig: 3.0.1 + dev: true + /@eslint/eslintrc/1.2.3: resolution: {integrity: sha512-uGo44hIwoLGNyduRpjdEpovcbMdd+Nv7amtmJxnKmI8xj6yd5LncmSwDa5NgX/41lIFJtkjD6YdVfgEzPfJ5UA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -4287,6 +4308,13 @@ packages: - supports-color dev: true + /esno/0.15.0: + resolution: {integrity: sha512-Wws1YgB/PBUtc/Pq755Crv2r5XIcSZyqC/9qyiczzQoDNNIUdxQ75uSd6gaMJFJ+pieljcH3f9JawmrHk0vLXw==} + hasBin: true + dependencies: + tsx: 2.0.1 + dev: true + /espree/9.3.2: resolution: {integrity: sha512-D211tC7ZwouTIuY5x9XnS0E9sWNChB7IYKX/Xp5eQj3nFXhqmiUDB9q27y76oFl8jTg3pXcQx/bpxMfs3CIZbA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -4688,6 +4716,10 @@ packages: resolution: {integrity: sha1-dKILqKSr7OWuGZrQPyvMaP38m6U=} dev: true + /get-tsconfig/3.0.1: + resolution: {integrity: sha512-+m30eQjbcf3xMNdnacXH5IDAKUMbI7Mhbf3e1BHif1FzBlUhBzBlmOVc7kL4+kB035l8OCyBdI3dNXZ3of9HqA==} + dev: true + /git-raw-commits/2.0.11: resolution: {integrity: sha512-VnctFhw+xfj8Va1xtfEqCUD2XDrbAPSJx+hSrE5K7fGdjZruW7XV+QOrN7LF/RJyvspRiD2I0asWsxFp0ya26A==} engines: {node: '>=10'} @@ -7988,37 +8020,6 @@ packages: yn: 3.1.1 dev: true - /ts-node/10.7.0_sm5zkxj4s52nbddwl76qwfh6ya: - resolution: {integrity: sha512-TbIGS4xgJoX2i3do417KSaep1uRAW/Lu+WAL2doDHC0D6ummjirVOXU5/7aiZotbQ5p1Zp9tP7U6cYhA0O7M8A==} - hasBin: true - peerDependencies: - '@swc/core': '>=1.2.50' - '@swc/wasm': '>=1.2.50' - '@types/node': '*' - typescript: '>=2.7' - peerDependenciesMeta: - '@swc/core': - optional: true - '@swc/wasm': - optional: true - dependencies: - '@cspotcode/source-map-support': 0.7.0 - '@tsconfig/node10': 1.0.8 - '@tsconfig/node12': 1.0.9 - '@tsconfig/node14': 1.0.1 - '@tsconfig/node16': 1.0.2 - '@types/node': 17.0.32 - acorn: 8.7.1 - acorn-walk: 8.2.0 - arg: 4.1.3 - create-require: 1.1.1 - diff: 4.0.2 - make-error: 1.3.6 - typescript: 4.6.4 - v8-compile-cache-lib: 3.0.1 - yn: 3.1.1 - dev: true - /tsconfck/2.0.0: resolution: {integrity: sha512-GVDTXF4MdNBBxKfUfjs/wkb7LHd8Ho8WLavESCddTFQFG9AUZOZEm6kODBGmQopQ9OG+EHpkT6dBaIIGhYVt+Q==} engines: {node: ^14.13.1 || ^16 || >=18, pnpm: ^7.0.1} @@ -8057,6 +8058,16 @@ packages: typescript: 4.6.4 dev: true + /tsx/2.0.1: + resolution: {integrity: sha512-qOzBwD5DkUodG7PjIUTPmRdAknYHC4jh7cOchnUScJCyayI8Cy8WqoD1rc7+zhM6x5a4YDoE5CJ+t3a92K4j2w==} + hasBin: true + dependencies: + '@esbuild-kit/cjs-loader': 1.0.0 + '@esbuild-kit/esm-loader': 1.0.0 + optionalDependencies: + fsevents: 2.3.2 + dev: true + /type-check/0.4.0: resolution: {integrity: sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==} engines: {node: '>= 0.8.0'} diff --git a/scripts/patchCJS.ts b/scripts/patchCJS.ts index 76edf3fcfa6da5..e225d9455e98dc 100644 --- a/scripts/patchCJS.ts +++ b/scripts/patchCJS.ts @@ -17,7 +17,7 @@ module.exports.parseVueRequest = parseVueRequest; */ import { readFileSync, writeFileSync } from 'fs' -import { bold, red } from 'picocolors' +import colors from 'picocolors' const indexPath = 'dist/index.cjs' let code = readFileSync(indexPath, 'utf-8') @@ -40,7 +40,7 @@ if (matchMixed) { writeFileSync(indexPath, lines.join('\n')) - console.log(bold(`${indexPath} CJS patched`)) + console.log(colors.bold(`${indexPath} CJS patched`)) process.exit() } @@ -49,9 +49,9 @@ const matchDefault = code.match(/\nmodule.exports = (\w+);/) if (matchDefault) { code += `module.exports["default"] = ${matchDefault[1]};\n` writeFileSync(indexPath, code) - console.log(bold(`${indexPath} CJS patched`)) + console.log(colors.bold(`${indexPath} CJS patched`)) process.exit() } -console.error(red(`${indexPath} CJS patch failed`)) +console.error(colors.red(`${indexPath} CJS patch failed`)) process.exit(1)