Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): use esno to replace ts-node #8152

Merged
merged 10 commits into from
May 13, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
"docs": "vitepress dev docs",
"build-docs": "vitepress build docs",
"serve-docs": "vitepress serve docs",
"release": "ts-node scripts/release.ts",
"ci-publish": "ts-node scripts/publishCI.ts",
"release": "esno scripts/release.ts",
"ci-publish": "esno scripts/publishCI.ts",
"typecheck": "tsc -p scripts --noEmit && tsc -p playground --noEmit",
"build": "run-s build-vite build-plugin-vue build-plugin-react",
"build-vite": "cd packages/vite && npm run build",
Expand Down Expand Up @@ -65,6 +65,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",
Expand All @@ -90,7 +91,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": {
"*": [
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"dev": "tsc -p . -w --incremental",
"build": "rimraf dist && run-s build-bundle build-types",
"build-bundle": "esbuild src/index.ts --bundle --platform=node --target=node12 --external:@babel/* --external:@rollup/* --external:resolve --external:react-refresh/* --outfile=dist/index.js && npm run patch-dist",
"patch-dist": "ts-node ../../scripts/patchEsbuildDist.ts dist/index.js viteReact",
"patch-dist": "esno ../../scripts/patchEsbuildDist.ts dist/index.js viteReact",
"build-types": "tsc -p . --emitDeclarationOnly --outDir temp && api-extractor run && rimraf temp",
"prepublishOnly": "(cd ../vite && npm run build) && npm run build"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"dev-watch": "esbuild src/index.ts --watch --bundle --platform=node --target=node12 --external:@vue/compiler-sfc --external:vue/compiler-sfc --external:vite --outfile=dist/index.js",
"build": "rimraf dist && run-s build-bundle build-types",
"build-bundle": "esbuild src/index.ts --bundle --platform=node --target=node12 --external:@vue/compiler-sfc --external:vue/compiler-sfc --external:vite --outfile=dist/index.js & npm run patch-dist",
"patch-dist": "ts-node ../../scripts/patchEsbuildDist.ts dist/index.js vuePlugin",
"patch-dist": "esno ../../scripts/patchEsbuildDist.ts dist/index.js vuePlugin",
"build-types": "tsc -p . --emitDeclarationOnly --outDir temp && api-extractor run && rimraf temp",
"prepublishOnly": "(cd ../vite && npm run build) && npm run build"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"build-types": "run-s build-temp-types patch-types roll-types",
"build-temp-types": "tsc --emitDeclarationOnly --outDir temp/node -p src/node",
"ci-build": "rimraf dist && run-s build-bundle build-types",
"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\"",
Expand Down
10 changes: 6 additions & 4 deletions packages/vite/scripts/patchTypes.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 1 addition & 2 deletions playground/tailwind/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"vue-router": "^4.0.15"
},
"devDependencies": {
"@vitejs/plugin-vue": "workspace:*",
"ts-node": "^10.7.0"
antfu marked this conversation as resolved.
Show resolved Hide resolved
"@vitejs/plugin-vue": "workspace:*"
}
}
99 changes: 48 additions & 51 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions scripts/patchEsbuildDist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// continue using it.

import { readFileSync, writeFileSync } from 'fs'
import { bold, red } from 'picocolors'
import colors from 'picocolors'

const indexPath = process.argv[2]
const varName = process.argv[3]
Expand All @@ -24,8 +24,8 @@ ${varName}['default'] = ${varName};`
writeFileSync(indexPath, code)

console.log(
bold(`${indexPath} patched with overwrite for cjs require('...')()`)
colors.bold(`${indexPath} patched with overwrite for cjs require('...')()`)
)
} else {
console.error(red(`${indexPath} post-esbuild bundling patch failed`))
console.error(colors.red(`${indexPath} post-esbuild bundling patch failed`))
}