Skip to content

Commit b84ccd5

Browse files
authored
Merge branch 'main' into remove-node-12-support
2 parents f63e3a0 + fc89057 commit b84ccd5

23 files changed

Lines changed: 229 additions & 118 deletions

File tree

.github/workflows/ci.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,17 @@ jobs:
2727
strategy:
2828
matrix:
2929
os: [ubuntu-latest]
30-
node_version: [14, 16, 17]
30+
node_version: [14, 16, 18]
3131
include:
3232
- os: macos-latest
3333
node_version: 16
34+
- os: macos-latest
35+
node_version: 18
3436
- os: windows-latest
3537
node_version: 16
38+
# Maybe bug with jest on windows and node-v18
39+
# - os: windows-latest
40+
# node_version: 18
3641
fail-fast: false
3742

3843
name: "Build&Test: node-${{ matrix.node_version }}, ${{ matrix.os }}"

CONTRIBUTING.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ test('should work', async () => {
9595

9696
Some common test helpers, e.g. `testDir`, `isBuild` or `editFile` are available in `packages/playground/testUtils.ts`.
9797

98+
Note: The test build environment uses a [different default set of Vite config](https://github.com/vitejs/vite/blob/9c6501d9c363eaa3c1e7708d531fb2a92b633db6/scripts/jestPerTestSetup.ts#L102-L122) to skip transpilation during tests to make it faster. This may produce a different result compared to the default production build.
99+
98100
### Extending the Test Suite
99101

100102
To add new tests, you should find a related playground to the fix or feature (or create a new one). As an example, static assets loading are tested in the [assets playground](https://github.com/vitejs/vite/tree/main/packages/playground/assets). In this Vite App, there is a test for `?raw` imports, with [a section is defined in the `index.html` for it](https://github.com/vitejs/vite/blob/71215533ac60e8ff566dc3467feabfc2c71a01e2/packages/playground/assets/index.html#L121):

docs/guide/api-hmr.md

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,27 @@ Vite exposes its manual HMR API via the special `import.meta.hot` object:
1010

1111
```ts
1212
interface ImportMeta {
13-
readonly hot?: {
14-
readonly data: any
13+
readonly hot?: ViteHotContext
14+
}
15+
16+
interface ViteHotContext {
17+
readonly data: any
1518

16-
accept(): void
17-
accept(cb: (mod: any) => void): void
18-
accept(dep: string, cb: (mod: any) => void): void
19-
accept(deps: string[], cb: (mods: any[]) => void): void
19+
accept(): void
20+
accept(cb: (mod: any) => void): void
21+
accept(dep: string, cb: (mod: any) => void): void
22+
accept(deps: readonly string[], cb: (mods: any[]) => void): void
2023

21-
prune(cb: () => void): void
22-
dispose(cb: (data: any) => void): void
23-
decline(): void
24-
invalidate(): void
24+
dispose(cb: (data: any) => void): void
25+
decline(): void
26+
invalidate(): void
2527

26-
on(event: string, cb: (...args: any[]) => void): void
27-
}
28+
// `InferCustomEventPayload` provides types for built-in Vite events
29+
on<T extends string>(
30+
event: T,
31+
cb: (payload: InferCustomEventPayload<T>) => void
32+
): void
33+
send<T extends string>(event: T, data?: InferCustomEventPayload<T>): void
2834
}
2935
```
3036

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"@microsoft/api-extractor": "^7.22.2",
3838
"@types/fs-extra": "^9.0.13",
3939
"@types/jest": "^27.4.1",
40-
"@types/node": "^16.11.27",
40+
"@types/node": "^17.0.25",
4141
"@types/prompts": "^2.0.14",
4242
"@types/semver": "^7.3.9",
4343
"@typescript-eslint/eslint-plugin": "^5.20.0",
@@ -46,12 +46,12 @@
4646
"cross-env": "^7.0.3",
4747
"esbuild": "^0.14.27",
4848
"eslint": "^8.13.0",
49-
"eslint-define-config": "^1.3.0",
49+
"eslint-define-config": "^1.4.0",
5050
"eslint-plugin-node": "^11.1.0",
5151
"execa": "^5.1.1",
5252
"fs-extra": "^10.1.0",
5353
"jest": "^27.5.1",
54-
"lint-staged": "^12.3.8",
54+
"lint-staged": "^12.4.0",
5555
"minimist": "^1.2.6",
5656
"node-fetch": "^2.6.6",
5757
"npm-run-all": "^4.1.5",

packages/playground/ssr-webworker/vite.config.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,18 @@ module.exports = {
1010
},
1111
ssr: {
1212
target: 'webworker',
13-
noExternal: true
13+
noExternal: ['this-should-be-replaced-by-the-boolean']
1414
},
1515
plugins: [
16+
{
17+
config() {
18+
return {
19+
ssr: {
20+
noExternal: true
21+
}
22+
}
23+
}
24+
},
1625
{
1726
config() {
1827
return {

packages/playground/worker/__tests__/es/es-worker.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ if (isBuild) {
6060
// assert correct files
6161
test('inlined code generation', async () => {
6262
const files = fs.readdirSync(assetsDir)
63-
expect(files.length).toBe(22)
63+
expect(files.length).toBe(21)
6464
const index = files.find((f) => f.includes('main-module'))
6565
const content = fs.readFileSync(path.resolve(assetsDir, index), 'utf-8')
6666
const worker = files.find((f) => f.includes('my-worker'))

packages/playground/worker/__tests__/iife/worker.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ if (isBuild) {
6363
// assert correct files
6464
test('inlined code generation', async () => {
6565
const files = fs.readdirSync(assetsDir)
66-
expect(files.length).toBe(13)
66+
expect(files.length).toBe(12)
6767
const index = files.find((f) => f.includes('main-module'))
6868
const content = fs.readFileSync(path.resolve(assetsDir, index), 'utf-8')
6969
const worker = files.find((f) => f.includes('my-worker'))

packages/playground/worker/__tests__/sourcemap-hidden/sourcemap-hidden-worker.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ if (isBuild) {
99
test('sourcemap generation for web workers', async () => {
1010
const files = fs.readdirSync(assetsDir)
1111
// should have 2 worker chunk
12-
expect(files.length).toBe(25)
12+
expect(files.length).toBe(24)
1313
const index = files.find((f) => f.includes('main-module'))
1414
const content = fs.readFileSync(path.resolve(assetsDir, index), 'utf-8')
1515
const indexSourcemap = getSourceMapUrl(content)

packages/playground/worker/__tests__/sourcemap-inline/sourcemap-inline-worker.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ if (isBuild) {
99
test('sourcemap generation for web workers', async () => {
1010
const files = fs.readdirSync(assetsDir)
1111
// should have 2 worker chunk
12-
expect(files.length).toBe(13)
12+
expect(files.length).toBe(12)
1313
const index = files.find((f) => f.includes('main-module'))
1414
const content = fs.readFileSync(path.resolve(assetsDir, index), 'utf-8')
1515
const indexSourcemap = getSourceMapUrl(content)

packages/playground/worker/__tests__/sourcemap/sourcemap-worker.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ if (isBuild) {
99
test('sourcemap generation for web workers', async () => {
1010
const files = fs.readdirSync(assetsDir)
1111
// should have 2 worker chunk
12-
expect(files.length).toBe(25)
12+
expect(files.length).toBe(24)
1313
const index = files.find((f) => f.includes('main-module'))
1414
const content = fs.readFileSync(path.resolve(assetsDir, index), 'utf-8')
1515
const indexSourcemap = getSourceMapUrl(content)

0 commit comments

Comments
 (0)