Skip to content

Commit d2a3931

Browse files
authored
chore: clean some leftovers from Vite core (#44)
1 parent 9094c8b commit d2a3931

File tree

10 files changed

+72
-971
lines changed

10 files changed

+72
-971
lines changed

.github/renovate.json5

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,12 @@
1313
],
1414
"ignoreDeps": [
1515
// manually bumping
16-
"esbuild",
1716
"rollup",
1817
"node",
1918
"typescript",
2019

2120
// breaking changes
2221
"source-map", // `source-map:v0.7.0+` needs more investigation
23-
"dotenv-expand", // `dotenv-expand:6.0.0+` has breaking changes (#6858)
2422
"kill-port", // `kill-port:^2.0.0 has perf issues (#8392)
25-
"miniflare", // `miniflare:v2.0.0+` only supports node 16.7
2623
],
2724
}

package.json

Lines changed: 3 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -30,61 +30,37 @@
3030
"release": "tsx scripts/release.ts"
3131
},
3232
"devDependencies": {
33-
"@babel/types": "^7.20.5",
34-
"@microsoft/api-extractor": "^7.33.6",
35-
"@rollup/plugin-typescript": "^10.0.1",
3633
"@types/babel__core": "^7.1.20",
37-
"@types/babel__standalone": "^7.1.4",
38-
"@types/convert-source-map": "^1.5.2",
39-
"@types/cross-spawn": "^6.0.2",
40-
"@types/debug": "^4.1.7",
41-
"@types/estree": "^1.0.0",
42-
"@types/etag": "^1.8.1",
4334
"@types/fs-extra": "^9.0.13",
44-
"@types/less": "^3.0.3",
45-
"@types/micromatch": "^4.0.2",
4635
"@types/minimist": "^1.2.2",
4736
"@types/node": "^17.0.42",
4837
"@types/picomatch": "^2.3.0",
4938
"@types/prompts": "^2.4.1",
50-
"@types/resolve": "^1.20.2",
51-
"@types/sass": "~1.43.1",
5239
"@types/semver": "^7.3.13",
53-
"@types/stylus": "^0.48.38",
54-
"@types/ws": "^8.5.3",
5540
"@typescript-eslint/eslint-plugin": "^5.44.0",
5641
"@typescript-eslint/parser": "^5.44.0",
5742
"conventional-changelog-cli": "^2.2.2",
58-
"esbuild": "^0.15.9",
5943
"eslint": "^8.28.0",
6044
"eslint-define-config": "^1.12.0",
6145
"eslint-plugin-import": "^2.26.0",
6246
"eslint-plugin-node": "^11.1.0",
6347
"eslint-plugin-regexp": "^1.11.0",
6448
"execa": "^6.1.0",
65-
"fast-glob": "^3.2.12",
6649
"fs-extra": "^10.1.0",
6750
"lint-staged": "^13.0.4",
6851
"minimist": "^1.2.7",
69-
"npm-run-all": "^4.1.5",
7052
"picocolors": "^1.0.0",
7153
"playwright-chromium": "^1.28.1",
72-
"pnpm": "^7.17.1",
7354
"prettier": "2.8.0",
7455
"prompts": "^2.4.2",
75-
"resolve": "^1.22.1",
76-
"rimraf": "^3.0.2",
77-
"rollup": "~3.3.0",
78-
"rollup-plugin-license": "^2.9.1",
56+
"rollup": "~3.5.0",
7957
"semver": "^7.3.8",
8058
"simple-git-hooks": "^2.8.1",
81-
"tslib": "^2.4.1",
8259
"tsx": "^3.12.1",
8360
"typescript": "^4.6.4",
8461
"unbuild": "^0.9.4",
8562
"vite": "^4.0.0-alpha.0",
86-
"vitest": "^0.25.3",
87-
"vue": "^3.2.45"
63+
"vitest": "^0.25.3"
8864
},
8965
"simple-git-hooks": {
9066
"pre-commit": "pnpm exec lint-staged --concurrent false",
@@ -104,19 +80,5 @@
10480
"eslint --cache --fix"
10581
]
10682
},
107-
"packageManager": "[email protected]",
108-
"pnpm": {
109-
"packageExtensions": {
110-
"postcss-load-config": {
111-
"peerDependencies": {
112-
"postcss": "*"
113-
}
114-
},
115-
"acorn-walk": {
116-
"peerDependencies": {
117-
"acorn": "*"
118-
}
119-
}
120-
}
121-
}
83+
"packageManager": "[email protected]"
12284
}

packages/plugin-react/tsconfig.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
"declaration": true,
1111
"sourceMap": true,
1212
"noUnusedLocals": true,
13-
"esModuleInterop": true,
14-
"paths": {
15-
"vite": ["../vite/src/node/index.js"]
16-
}
13+
"esModuleInterop": true
1714
}
1815
}

playground/package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33
"private": true,
44
"version": "1.0.0",
55
"devDependencies": {
6-
"convert-source-map": "^1.9.0",
76
"css-color-names": "^1.0.1",
87
"kill-port": "^1.6.1",
9-
"node-fetch": "^3.3.0",
10-
"sirv": "^2.0.2"
8+
"node-fetch": "^3.3.0"
119
}
1210
}

playground/shims.d.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,3 @@ declare module 'kill-port' {
77
const kill: (port: number) => Promise<void>
88
export default kill
99
}
10-
11-
declare module '*.vue' {
12-
import type { ComponentOptions } from 'vue'
13-
const component: ComponentOptions
14-
export default component
15-
}

playground/test-utils.ts

Lines changed: 4 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -5,42 +5,17 @@ import fs from 'node:fs'
55
import path from 'node:path'
66
import colors from 'css-color-names'
77
import type { ConsoleMessage, ElementHandle } from 'playwright-chromium'
8-
import type { Manifest } from 'vite'
9-
import { normalizePath } from 'vite'
10-
import { fromComment } from 'convert-source-map'
118
import { expect } from 'vitest'
12-
import type { ExecaChildProcess } from 'execa'
13-
import { isBuild, isWindows, page, testDir } from './vitestSetup'
9+
import { isBuild, page, testDir } from './vitestSetup'
1410

1511
export * from './vitestSetup'
1612

1713
// make sure these ports are unique
1814
export const ports = {
19-
cli: 9510,
20-
'cli-module': 9511,
21-
'legacy/ssr': 9520,
22-
lib: 9521,
23-
'optimize-missing-deps': 9522,
24-
'legacy/client-and-ssr': 9523,
25-
'ssr-deps': 9600,
26-
'ssr-html': 9601,
27-
'ssr-noexternal': 9602,
28-
'ssr-pug': 9603,
2915
'ssr-react': 9604,
30-
'ssr-vue': 9605,
31-
'ssr-webworker': 9606,
32-
'css/postcss-caching': 5005,
33-
'css/postcss-plugins-different-dir': 5006,
34-
'css/dynamic-import': 5007,
3516
}
3617
export const hmrPorts = {
37-
'optimize-missing-deps': 24680,
38-
'ssr-deps': 24681,
39-
'ssr-html': 24682,
40-
'ssr-noexternal': 24683,
41-
'ssr-pug': 24684,
4218
'ssr-react': 24685,
43-
'ssr-vue': 24686,
4419
}
4520

4621
const hexToNameMap: Record<string, string> = {}
@@ -117,38 +92,6 @@ export function removeFile(filename: string): void {
11792
fs.unlinkSync(path.resolve(testDir, filename))
11893
}
11994

120-
export function listAssets(base = ''): string[] {
121-
const assetsDir = path.join(testDir, 'dist', base, 'assets')
122-
return fs.readdirSync(assetsDir)
123-
}
124-
125-
export function findAssetFile(
126-
match: string | RegExp,
127-
base = '',
128-
assets = 'assets',
129-
): string {
130-
const assetsDir = path.join(testDir, 'dist', base, assets)
131-
let files: string[]
132-
try {
133-
files = fs.readdirSync(assetsDir)
134-
} catch (e) {
135-
if (e.code === 'ENOENT') {
136-
return ''
137-
}
138-
throw e
139-
}
140-
const file = files.find((file) => {
141-
return file.match(match)
142-
})
143-
return file ? fs.readFileSync(path.resolve(assetsDir, file), 'utf-8') : ''
144-
}
145-
146-
export function readManifest(base = ''): Manifest {
147-
return JSON.parse(
148-
fs.readFileSync(path.join(testDir, 'dist', base, 'manifest.json'), 'utf-8'),
149-
)
150-
}
151-
15295
/**
15396
* Poll a getter until the value it returns includes the expected value.
15497
*/
@@ -170,25 +113,6 @@ export async function untilUpdated(
170113
}
171114
}
172115

173-
/**
174-
* Retry `func` until it does not throw error.
175-
*/
176-
export async function withRetry(
177-
func: () => Promise<void>,
178-
runInBuild = false,
179-
): Promise<void> {
180-
if (isBuild && !runInBuild) return
181-
const maxTries = process.env.CI ? 200 : 50
182-
for (let tries = 0; tries < maxTries; tries++) {
183-
try {
184-
await func()
185-
return
186-
} catch {}
187-
await timeout(50)
188-
}
189-
await func()
190-
}
191-
192116
type UntilBrowserLogAfterCallback = (logs: string[]) => PromiseLike<void> | void
193117

194118
export async function untilBrowserLogAfter(
@@ -288,32 +212,6 @@ async function untilBrowserLog(
288212
return logs
289213
}
290214

291-
export const extractSourcemap = (content: string): any => {
292-
const lines = content.trim().split('\n')
293-
return fromComment(lines[lines.length - 1]).toObject()
294-
}
295-
296-
export const formatSourcemapForSnapshot = (map: any): any => {
297-
const root = normalizePath(testDir)
298-
const m = { ...map }
299-
delete m.file
300-
delete m.names
301-
m.sources = m.sources.map((source) => source.replace(root, '/root'))
302-
return m
303-
}
304-
305-
// helper function to kill process, uses taskkill on windows to ensure child process is killed too
306-
export async function killProcess(
307-
serverProcess: ExecaChildProcess,
308-
): Promise<void> {
309-
if (isWindows) {
310-
try {
311-
const { execaCommandSync } = await import('execa')
312-
execaCommandSync(`taskkill /pid ${serverProcess.pid} /T /F`)
313-
} catch (e) {
314-
console.error('failed to taskkill:', e)
315-
}
316-
} else {
317-
serverProcess.kill('SIGTERM', { forceKillAfterTimeout: 2000 })
318-
}
319-
}
215+
/**
216+
* Before implementing a new util, check if it's not available in core https://github.com/vitejs/vite/blob/main/playground/test-utils.ts
217+
*/

0 commit comments

Comments
 (0)