Skip to content

Commit

Permalink
chore: revert #8152 (#8161)
Browse files Browse the repository at this point in the history
This reverts commit 2363bd3.
  • Loading branch information
antfu authored May 13, 2022
1 parent 2363bd3 commit 85b8b55
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 64 deletions.
1 change: 1 addition & 0 deletions .github/renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"esbuild",
"rollup",
"node",
"ts-node",
"typescript",

// breaking changes
Expand Down
1 change: 0 additions & 1 deletion .npmrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ hoist-pattern[]=@emotion/*
hoist-pattern[]=postcss
hoist-pattern[]=pug
hoist-pattern[]=source-map-support
hoist-pattern[]=ts-node
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "esno scripts/release.ts",
"ci-publish": "esno scripts/publishCI.ts",
"release": "ts-node scripts/release.ts",
"ci-publish": "ts-node scripts/publishCI.ts",
"ci-docs": "run-s build docs-build"
},
"devDependencies": {
Expand Down Expand Up @@ -63,7 +63,6 @@
"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 @@ -80,6 +79,7 @@
"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:*",
Expand All @@ -89,7 +89,7 @@
},
"simple-git-hooks": {
"pre-commit": "pnpm exec lint-staged --concurrent false",
"commit-msg": "pnpm exec esno scripts/verifyCommit.ts $1"
"commit-msg": "pnpm exec ts-node scripts/verifyCommit.ts $1"
},
"lint-staged": {
"*": [
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-legacy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"scripts": {
"dev": "unbuild --stub",
"build": "unbuild && pnpm run patch-cjs",
"patch-cjs": "esno ../../scripts/patchCJS.ts",
"patch-cjs": "ts-node ../../scripts/patchCJS.ts",
"prepublishOnly": "npm run build"
},
"engines": {
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 @@ -23,7 +23,7 @@
"scripts": {
"dev": "unbuild --stub",
"build": "unbuild && pnpm run patch-cjs",
"patch-cjs": "esno ../../scripts/patchCJS.ts",
"patch-cjs": "ts-node ../../scripts/patchCJS.ts",
"prepublishOnly": "npm run build"
},
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-vue-jsx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"scripts": {
"dev": "unbuild --stub",
"build": "unbuild && pnpm run patch-cjs",
"patch-cjs": "esno ../../scripts/patchCJS.ts",
"patch-cjs": "ts-node ../../scripts/patchCJS.ts",
"prepublishOnly": "npm run build"
},
"engines": {
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 @@ -19,7 +19,7 @@
"scripts": {
"dev": "unbuild --stub",
"build": "unbuild && pnpm run patch-cjs",
"patch-cjs": "esno ../../scripts/patchCJS.ts",
"patch-cjs": "ts-node ../../scripts/patchCJS.ts",
"prepublishOnly": "npm run build"
},
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "esno scripts/patchTypes.ts",
"patch-types": "ts-node 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: 4 additions & 6 deletions packages/vite/scripts/patchTypes.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
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 dir = dirname(fileURLToPath(import.meta.url))
const tempDir = resolve(dir, '../temp/node')
const typesDir = resolve(dir, '../types')
const tempDir = resolve(__dirname, '../temp/node')
const typesDir = resolve(__dirname, '../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
77 changes: 33 additions & 44 deletions pnpm-lock.yaml

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

8 changes: 4 additions & 4 deletions scripts/patchCJS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module.exports.parseVueRequest = parseVueRequest;
*/

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

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

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

console.log(colors.bold(`${indexPath} CJS patched`))
console.log(bold(`${indexPath} CJS patched`))
process.exit()
}

Expand All @@ -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(colors.bold(`${indexPath} CJS patched`))
console.log(bold(`${indexPath} CJS patched`))
process.exit()
}

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

0 comments on commit 85b8b55

Please sign in to comment.