Skip to content

Commit c18a5f3

Browse files
antfupatak-dev
andauthored
chore: use esno to replace ts-node (#8162)
Co-authored-by: patak-dev <[email protected]>
1 parent 5791f5d commit c18a5f3

File tree

10 files changed

+32
-50
lines changed

10 files changed

+32
-50
lines changed

.github/renovate.json5

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
"esbuild",
1717
"rollup",
1818
"node",
19-
"ts-node",
2019
"typescript",
2120

2221
// breaking changes

.npmrc

+1
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ hoist-pattern[]=@emotion/*
44
hoist-pattern[]=postcss
55
hoist-pattern[]=pug
66
hoist-pattern[]=source-map-support
7+
hoist-pattern[]=ts-node

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
"docs-serve": "vitepress serve docs",
2929
"build": "pnpm -r --filter=./packages/* run build",
3030
"dev": "pnpm -r --parallel --filter=./packages/* run dev",
31-
"release": "ts-node scripts/release.ts",
32-
"ci-publish": "ts-node scripts/publishCI.ts",
31+
"release": "esno scripts/release.ts",
32+
"ci-publish": "esno scripts/publishCI.ts",
3333
"ci-docs": "run-s build docs-build"
3434
},
3535
"devDependencies": {
@@ -64,6 +64,7 @@
6464
"eslint-define-config": "^1.4.0",
6565
"eslint-plugin-import": "^2.26.0",
6666
"eslint-plugin-node": "^11.1.0",
67+
"esno": "^0.16.3",
6768
"execa": "^5.1.1",
6869
"fs-extra": "^10.1.0",
6970
"kill-port": "^1.6.1",
@@ -81,7 +82,6 @@
8182
"semver": "^7.3.7",
8283
"simple-git-hooks": "^2.7.0",
8384
"sirv": "^2.0.2",
84-
"ts-node": "^10.7.0",
8585
"tslib": "^2.4.0",
8686
"typescript": "^4.6.4",
8787
"unbuild": "^0.7.4",
@@ -92,7 +92,7 @@
9292
},
9393
"simple-git-hooks": {
9494
"pre-commit": "pnpm exec lint-staged --concurrent false",
95-
"commit-msg": "pnpm exec ts-node scripts/verifyCommit.ts $1"
95+
"commit-msg": "pnpm exec esno scripts/verifyCommit.ts $1"
9696
},
9797
"lint-staged": {
9898
"*": [

packages/plugin-legacy/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"scripts": {
2020
"dev": "unbuild --stub",
2121
"build": "unbuild && pnpm run patch-cjs",
22-
"patch-cjs": "ts-node ../../scripts/patchCJS.ts",
22+
"patch-cjs": "esno ../../scripts/patchCJS.ts",
2323
"prepublishOnly": "npm run build"
2424
},
2525
"engines": {

packages/plugin-react/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"scripts": {
2424
"dev": "unbuild --stub",
2525
"build": "unbuild && pnpm run patch-cjs",
26-
"patch-cjs": "ts-node ../../scripts/patchCJS.ts",
26+
"patch-cjs": "esno ../../scripts/patchCJS.ts",
2727
"prepublishOnly": "npm run build"
2828
},
2929
"engines": {

packages/plugin-vue-jsx/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"scripts": {
2020
"dev": "unbuild --stub",
2121
"build": "unbuild && pnpm run patch-cjs",
22-
"patch-cjs": "ts-node ../../scripts/patchCJS.ts",
22+
"patch-cjs": "esno ../../scripts/patchCJS.ts",
2323
"prepublishOnly": "npm run build"
2424
},
2525
"engines": {

packages/plugin-vue/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"scripts": {
2020
"dev": "unbuild --stub",
2121
"build": "unbuild && pnpm run patch-cjs",
22-
"patch-cjs": "ts-node ../../scripts/patchCJS.ts",
22+
"patch-cjs": "esno ../../scripts/patchCJS.ts",
2323
"prepublishOnly": "npm run build"
2424
},
2525
"engines": {

packages/vite/scripts/patchTypes.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@ import type { File } from '@babel/types'
77
import colors from 'picocolors'
88
import MagicString from 'magic-string'
99

10-
// @ts-ignore
11-
const __dirname = resolve(fileURLToPath(import.meta.url), '..')
12-
13-
const tempDir = resolve(__dirname, '../temp/node')
14-
const typesDir = resolve(__dirname, '../types')
10+
const dir = dirname(fileURLToPath(import.meta.url))
11+
const tempDir = resolve(dir, '../temp/node')
12+
const typesDir = resolve(dir, '../types')
1513

1614
// walk through the temp dts dir, find all import/export of types/*
1715
// and rewrite them into relative imports - so that api-extractor actually

pnpm-lock.yaml

+16-32
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/patchCJS.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module.exports.parseVueRequest = parseVueRequest;
1717
*/
1818

1919
import { readFileSync, writeFileSync } from 'fs'
20-
import { bold, red } from 'picocolors'
20+
import colors from 'picocolors'
2121

2222
const indexPath = 'dist/index.cjs'
2323
let code = readFileSync(indexPath, 'utf-8')
@@ -40,7 +40,7 @@ if (matchMixed) {
4040

4141
writeFileSync(indexPath, lines.join('\n'))
4242

43-
console.log(bold(`${indexPath} CJS patched`))
43+
console.log(colors.bold(`${indexPath} CJS patched`))
4444
process.exit()
4545
}
4646

@@ -49,9 +49,9 @@ const matchDefault = code.match(/\nmodule.exports = (\w+);/)
4949
if (matchDefault) {
5050
code += `module.exports["default"] = ${matchDefault[1]};\n`
5151
writeFileSync(indexPath, code)
52-
console.log(bold(`${indexPath} CJS patched`))
52+
console.log(colors.bold(`${indexPath} CJS patched`))
5353
process.exit()
5454
}
5555

56-
console.error(red(`${indexPath} CJS patch failed`))
56+
console.error(colors.red(`${indexPath} CJS patch failed`))
5757
process.exit(1)

0 commit comments

Comments
 (0)