From 8db40ee5de67047e7f31a4d0cd27c6e86c91449c Mon Sep 17 00:00:00 2001 From: ihch Date: Tue, 31 Oct 2023 02:17:20 +0900 Subject: [PATCH 1/9] fix(worker): force rollup to build workerImportMetaUrl under watch mode (#14712) --- packages/vite/src/node/plugins/worker.ts | 2 +- .../src/node/plugins/workerImportMetaUrl.ts | 24 ++++++++++++++----- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/packages/vite/src/node/plugins/worker.ts b/packages/vite/src/node/plugins/worker.ts index b4f26f83355552..0df6f9d843e99c 100644 --- a/packages/vite/src/node/plugins/worker.ts +++ b/packages/vite/src/node/plugins/worker.ts @@ -218,7 +218,7 @@ export function webWorkerPlugin(config: ResolvedConfig): Plugin { }, shouldTransformCachedModule({ id }) { - if (isBuild && isWorkerQueryId(id) && config.build.watch) { + if (isBuild && config.build.watch && isWorkerQueryId(id)) { return true } }, diff --git a/packages/vite/src/node/plugins/workerImportMetaUrl.ts b/packages/vite/src/node/plugins/workerImportMetaUrl.ts index 85ec7c5b57240e..e88d1ac3362a43 100644 --- a/packages/vite/src/node/plugins/workerImportMetaUrl.ts +++ b/packages/vite/src/node/plugins/workerImportMetaUrl.ts @@ -96,6 +96,17 @@ function getWorkerType(raw: string, clean: string, i: number): WorkerType { return 'classic' } +function isIncludeWorkerImportMetaUrl(code: string): boolean { + if ( + (code.includes('new Worker') || code.includes('new SharedWorker')) && + code.includes('new URL') && + code.includes(`import.meta.url`) + ) { + return true + } + return false +} + export function workerImportMetaUrlPlugin(config: ResolvedConfig): Plugin { const isBuild = config.command === 'build' let workerResolver: ResolveFn @@ -113,14 +124,15 @@ export function workerImportMetaUrlPlugin(config: ResolvedConfig): Plugin { return { name: 'vite:worker-import-meta-url', + shouldTransformCachedModule({ code }) { + if (isBuild && config.build.watch && isIncludeWorkerImportMetaUrl(code)) { + return true + } + }, + async transform(code, id, options) { const ssr = options?.ssr === true - if ( - !options?.ssr && - (code.includes('new Worker') || code.includes('new SharedWorker')) && - code.includes('new URL') && - code.includes(`import.meta.url`) - ) { + if (!options?.ssr && isIncludeWorkerImportMetaUrl(code)) { const query = parseRequest(id) let s: MagicString | undefined const cleanString = stripLiteral(code) From 2124264ceebce83d94116aa53f6db9bed5e8af4b Mon Sep 17 00:00:00 2001 From: bluwy Date: Tue, 31 Oct 2023 01:25:38 +0800 Subject: [PATCH 2/9] release: v5.0.0-beta.14 --- packages/vite/CHANGELOG.md | 14 ++++++++++++++ packages/vite/package.json | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/packages/vite/CHANGELOG.md b/packages/vite/CHANGELOG.md index b347bef79d7bf4..d9046ab3e84b26 100644 --- a/packages/vite/CHANGELOG.md +++ b/packages/vite/CHANGELOG.md @@ -1,3 +1,17 @@ +## 5.0.0-beta.14 (2023-10-30) + +* fix(define): correctly replace same define values (#14786) ([f36fcd2](https://github.com/vitejs/vite/commit/f36fcd2)), closes [#14786](https://github.com/vitejs/vite/issues/14786) +* fix(deps): update all non-major dependencies (#14729) ([d5d96e7](https://github.com/vitejs/vite/commit/d5d96e7)), closes [#14729](https://github.com/vitejs/vite/issues/14729) +* fix(worker): force rollup to build workerImportMetaUrl under watch mode (#14712) ([8db40ee](https://github.com/vitejs/vite/commit/8db40ee)), closes [#14712](https://github.com/vitejs/vite/issues/14712) +* fix(html)!: align html serving between dev and preview (#14756) ([4f71ae8](https://github.com/vitejs/vite/commit/4f71ae8)), closes [#14756](https://github.com/vitejs/vite/issues/14756) +* refactor!: remove non boolean middleware mode (#14792) ([deb5515](https://github.com/vitejs/vite/commit/deb5515)), closes [#14792](https://github.com/vitejs/vite/issues/14792) +* refactor(esbuild)!: remove esbuild 0.17 -> 0.18 compat (#14804) ([7234021](https://github.com/vitejs/vite/commit/7234021)), closes [#14804](https://github.com/vitejs/vite/issues/14804) +* chore: update license (#14790) ([ac5d8a7](https://github.com/vitejs/vite/commit/ac5d8a7)), closes [#14790](https://github.com/vitejs/vite/issues/14790) +* chore(shortcuts): resolve generic type error (#14802) ([a090742](https://github.com/vitejs/vite/commit/a090742)), closes [#14802](https://github.com/vitejs/vite/issues/14802) +* feat: add a runtime warning for the old object type transformIndexHtml hook (#14791) ([17fb5ee](https://github.com/vitejs/vite/commit/17fb5ee)), closes [#14791](https://github.com/vitejs/vite/issues/14791) + + + ## 5.0.0-beta.13 (2023-10-27) * fix: skip watchPackageDataPlugin for worker builds (#14762) ([9babef5](https://github.com/vitejs/vite/commit/9babef5)), closes [#14762](https://github.com/vitejs/vite/issues/14762) diff --git a/packages/vite/package.json b/packages/vite/package.json index 831a138585f27f..01171876960274 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -1,6 +1,6 @@ { "name": "vite", - "version": "5.0.0-beta.13", + "version": "5.0.0-beta.14", "type": "module", "license": "MIT", "author": "Evan You", From bd1553769b826f2bcd3100f2b603a2de7058ea26 Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Tue, 31 Oct 2023 14:21:28 +0800 Subject: [PATCH 3/9] perf(define): create simple regex for checks (#14788) --- .../src/node/__tests__/plugins/define.spec.ts | 10 +++++++++ packages/vite/src/node/plugins/define.ts | 22 +++++++++---------- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/packages/vite/src/node/__tests__/plugins/define.spec.ts b/packages/vite/src/node/__tests__/plugins/define.spec.ts index 2ac85712b2a072..8876a9d7ecc3e2 100644 --- a/packages/vite/src/node/__tests__/plugins/define.spec.ts +++ b/packages/vite/src/node/__tests__/plugins/define.spec.ts @@ -32,6 +32,16 @@ describe('definePlugin', () => { ) }) + test('should not replace if not defined', async () => { + const transform = await createDefinePluginTransform({ + __APP_VERSION__: JSON.stringify('1.0'), + }) + expect(await transform('const version = "1.0";')).toBe(undefined) + expect(await transform('const version = import.meta.SOMETHING')).toBe( + undefined, + ) + }) + test('replaces import.meta.env.SSR with false', async () => { const transform = await createDefinePluginTransform() expect(await transform('const isSSR = import.meta.env.SSR;')).toBe( diff --git a/packages/vite/src/node/plugins/define.ts b/packages/vite/src/node/plugins/define.ts index ccd6a5571a6e39..cce969843bfdde 100644 --- a/packages/vite/src/node/plugins/define.ts +++ b/packages/vite/src/node/plugins/define.ts @@ -83,18 +83,16 @@ export function definePlugin(config: ResolvedConfig): Plugin { }) } - const defineKeys = Object.keys(define) - const pattern = defineKeys.length - ? new RegExp( - // Mustn't be preceded by a char that can be part of an identifier - // or a '.' that isn't part of a spread operator - '(? Date: Tue, 31 Oct 2023 22:08:32 +0800 Subject: [PATCH 4/9] chore: fix typo (#14820) --- packages/vite/src/node/config.ts | 2 +- packages/vite/src/node/server/transformRequest.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/vite/src/node/config.ts b/packages/vite/src/node/config.ts index 207b949cc7e83c..d99d135447c045 100644 --- a/packages/vite/src/node/config.ts +++ b/packages/vite/src/node/config.ts @@ -259,7 +259,7 @@ export interface UserConfig { */ format?: 'es' | 'iife' /** - * Vite plugins that apply to worker bundle. The plugins retured by this function + * Vite plugins that apply to worker bundle. The plugins returned by this function * should be new instances every time it is called, because they are used for each * rollup worker bundling process. */ diff --git a/packages/vite/src/node/server/transformRequest.ts b/packages/vite/src/node/server/transformRequest.ts index 5b485ed6c7b9c7..e6bcfeae394732 100644 --- a/packages/vite/src/node/server/transformRequest.ts +++ b/packages/vite/src/node/server/transformRequest.ts @@ -397,7 +397,7 @@ async function handleModuleSoftInvalidation( if (ssr ? mod.ssrTransformResult : mod.transformResult) { throw new Error( - `Internal server error: Soft-invalidated module "${mod.url}" should not have existing tranform result`, + `Internal server error: Soft-invalidated module "${mod.url}" should not have existing transform result`, ) } From 884365ac355ec8a8f94dc8cc07af601fe8c1b523 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 31 Oct 2023 22:32:22 +0800 Subject: [PATCH 5/9] chore(deps): update tj-actions/changed-files action to v40 (#14800) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cb90d098eb1d47..83948b84d2cf07 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -58,7 +58,7 @@ jobs: - name: Get changed files id: changed-files - uses: tj-actions/changed-files@fea790cb660e33aef4bdf07304e28fedd77dfa13 # v39.2.4 + uses: tj-actions/changed-files@bfc49f4cff6934aa236c171f9bcbf1dd6b1ef438 # v40.0.1 with: files: | docs/** From 86a5356721f64de8033c559d4afa1e045ca672d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=20/=20green?= Date: Tue, 31 Oct 2023 23:58:17 +0900 Subject: [PATCH 6/9] feat: upgrade rollup to 4.2.0 and use parseAstAsync (#14821) --- package.json | 2 +- packages/vite/package.json | 2 +- packages/vite/src/node/ssr/ssrTransform.ts | 4 +- pnpm-lock.yaml | 150 ++++++++++----------- 4 files changed, 79 insertions(+), 79 deletions(-) diff --git a/package.json b/package.json index ea149187ad9dd5..d5b23c7b03118e 100644 --- a/package.json +++ b/package.json @@ -76,7 +76,7 @@ "playwright-chromium": "^1.39.0", "prettier": "3.0.3", "rimraf": "^5.0.5", - "rollup": "^4.1.4", + "rollup": "^4.2.0", "simple-git-hooks": "^2.9.0", "tslib": "^2.6.2", "tsx": "^3.14.0", diff --git a/packages/vite/package.json b/packages/vite/package.json index 01171876960274..1bb14cc3450cdc 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -76,7 +76,7 @@ "dependencies": { "esbuild": "^0.19.3", "postcss": "^8.4.31", - "rollup": "^4.1.4" + "rollup": "^4.2.0" }, "optionalDependencies": { "fsevents": "~2.3.3" diff --git a/packages/vite/src/node/ssr/ssrTransform.ts b/packages/vite/src/node/ssr/ssrTransform.ts index b0e9d0133d67cf..450890af8d0765 100644 --- a/packages/vite/src/node/ssr/ssrTransform.ts +++ b/packages/vite/src/node/ssr/ssrTransform.ts @@ -12,7 +12,7 @@ import type { import { extract_names as extractNames } from 'periscopic' import { walk as eswalk } from 'estree-walker' import type { RawSourceMap } from '@ampproject/remapping' -import { parseAst as rollupParseAst } from 'rollup/parseAst' +import { parseAstAsync as rollupParseAstAsync } from 'rollup/parseAst' import type { TransformResult } from '../server/transformRequest' import { combineSourcemaps } from '../utils' import { isJSONRequest } from '../plugins/json' @@ -75,7 +75,7 @@ async function ssrTransformScript( let ast: any try { - ast = rollupParseAst(code) + ast = await rollupParseAstAsync(code) } catch (err) { if (!err.loc || !err.loc.line) throw err const line = err.loc.line diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3987537ee49d5b..19a4eacaab72bf 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -32,7 +32,7 @@ importers: version: 7.23.0 '@rollup/plugin-typescript': specifier: ^11.1.5 - version: 11.1.5(rollup@4.1.4)(tslib@2.6.2)(typescript@5.2.2) + version: 11.1.5(rollup@4.2.0)(tslib@2.6.2)(typescript@5.2.2) '@types/babel__core': specifier: ^7.20.3 version: 7.20.3 @@ -133,8 +133,8 @@ importers: specifier: ^5.0.5 version: 5.0.5 rollup: - specifier: ^4.1.4 - version: 4.1.4 + specifier: ^4.2.0 + version: 4.2.0 simple-git-hooks: specifier: ^2.9.0 version: 2.9.0 @@ -230,8 +230,8 @@ importers: specifier: ^8.4.31 version: 8.4.31 rollup: - specifier: ^4.1.4 - version: 4.1.4 + specifier: ^4.2.0 + version: 4.2.0 optionalDependencies: fsevents: specifier: ~2.3.3 @@ -245,25 +245,25 @@ importers: version: 0.3.20 '@rollup/plugin-alias': specifier: ^5.0.1 - version: 5.0.1(rollup@4.1.4) + version: 5.0.1(rollup@4.2.0) '@rollup/plugin-commonjs': specifier: ^25.0.7 - version: 25.0.7(rollup@4.1.4) + version: 25.0.7(rollup@4.2.0) '@rollup/plugin-dynamic-import-vars': specifier: ^2.1.0 - version: 2.1.0(rollup@4.1.4) + version: 2.1.0(rollup@4.2.0) '@rollup/plugin-json': specifier: ^6.0.1 - version: 6.0.1(rollup@4.1.4) + version: 6.0.1(rollup@4.2.0) '@rollup/plugin-node-resolve': specifier: 15.2.3 - version: 15.2.3(rollup@4.1.4) + version: 15.2.3(rollup@4.2.0) '@rollup/plugin-typescript': specifier: ^11.1.5 - version: 11.1.5(rollup@4.1.4)(tslib@2.6.2)(typescript@5.2.2) + version: 11.1.5(rollup@4.2.0)(tslib@2.6.2)(typescript@5.2.2) '@rollup/pluginutils': specifier: ^5.0.5 - version: 5.0.5(rollup@4.1.4) + version: 5.0.5(rollup@4.2.0) '@types/escape-html': specifier: ^1.0.3 version: 1.0.3 @@ -377,10 +377,10 @@ importers: version: 2.0.2 rollup-plugin-dts: specifier: ^6.1.0 - version: 6.1.0(rollup@4.1.4)(typescript@5.2.2) + version: 6.1.0(rollup@4.2.0)(typescript@5.2.2) rollup-plugin-license: specifier: ^3.2.0 - version: 3.2.0(rollup@4.1.4) + version: 3.2.0(rollup@4.2.0) sirv: specifier: ^2.0.3 version: 2.0.3(patch_hash=z45f224eewh2pgpijxcc3aboqm) @@ -3421,7 +3421,7 @@ packages: slash: 4.0.0 dev: true - /@rollup/plugin-alias@5.0.1(rollup@4.1.4): + /@rollup/plugin-alias@5.0.1(rollup@4.2.0): resolution: {integrity: sha512-JObvbWdOHoMy9W7SU0lvGhDtWq9PllP5mjpAy+TUslZG/WzOId9u80Hsqq1vCUn9pFJ0cxpdcnAv+QzU2zFH3Q==} engines: {node: '>=14.0.0'} peerDependencies: @@ -3430,7 +3430,7 @@ packages: rollup: optional: true dependencies: - rollup: 4.1.4 + rollup: 4.2.0 slash: 4.0.0 dev: true @@ -3452,7 +3452,7 @@ packages: rollup: 3.29.2 dev: true - /@rollup/plugin-commonjs@25.0.7(rollup@4.1.4): + /@rollup/plugin-commonjs@25.0.7(rollup@4.2.0): resolution: {integrity: sha512-nEvcR+LRjEjsaSsc4x3XZfCCvZIaSMenZu/OiwOKGN2UhQpAYI7ru7czFvyWbErlpoGjnSX3D5Ch5FcMA3kRWQ==} engines: {node: '>=14.0.0'} peerDependencies: @@ -3461,16 +3461,16 @@ packages: rollup: optional: true dependencies: - '@rollup/pluginutils': 5.0.5(rollup@4.1.4) + '@rollup/pluginutils': 5.0.5(rollup@4.2.0) commondir: 1.0.1 estree-walker: 2.0.2 glob: 8.1.0 is-reference: 1.2.1 magic-string: 0.30.5 - rollup: 4.1.4 + rollup: 4.2.0 dev: true - /@rollup/plugin-dynamic-import-vars@2.1.0(rollup@4.1.4): + /@rollup/plugin-dynamic-import-vars@2.1.0(rollup@4.2.0): resolution: {integrity: sha512-hv+gJohx8HLPByLcuNxzzZw1/Ioi96qBzyMf3DIh/Zz0AHr7W/mknRYjqQaW/SF9UcuM2iYueSI+R4orbraj2Q==} engines: {node: '>=14.0.0'} peerDependencies: @@ -3479,12 +3479,12 @@ packages: rollup: optional: true dependencies: - '@rollup/pluginutils': 5.0.5(rollup@4.1.4) + '@rollup/pluginutils': 5.0.5(rollup@4.2.0) astring: 1.8.6 estree-walker: 2.0.2 fast-glob: 3.3.1 magic-string: 0.30.5 - rollup: 4.1.4 + rollup: 4.2.0 dev: true /@rollup/plugin-json@6.0.0(rollup@3.29.2): @@ -3500,7 +3500,7 @@ packages: rollup: 3.29.2 dev: true - /@rollup/plugin-json@6.0.1(rollup@4.1.4): + /@rollup/plugin-json@6.0.1(rollup@4.2.0): resolution: {integrity: sha512-RgVfl5hWMkxN1h/uZj8FVESvPuBJ/uf6ly6GTj0GONnkfoBN5KC0MSz+PN2OLDgYXMhtG0mWpTrkiOjoxAIevw==} engines: {node: '>=14.0.0'} peerDependencies: @@ -3509,8 +3509,8 @@ packages: rollup: optional: true dependencies: - '@rollup/pluginutils': 5.0.5(rollup@4.1.4) - rollup: 4.1.4 + '@rollup/pluginutils': 5.0.5(rollup@4.2.0) + rollup: 4.2.0 dev: true /@rollup/plugin-node-resolve@15.2.1(rollup@3.29.2): @@ -3531,7 +3531,7 @@ packages: rollup: 3.29.2 dev: true - /@rollup/plugin-node-resolve@15.2.3(rollup@4.1.4): + /@rollup/plugin-node-resolve@15.2.3(rollup@4.2.0): resolution: {integrity: sha512-j/lym8nf5E21LwBT4Df1VD6hRO2L2iwUeUmP7litikRsVp1H6NWx20NEp0Y7su+7XGc476GnXXc4kFeZNGmaSQ==} engines: {node: '>=14.0.0'} peerDependencies: @@ -3540,13 +3540,13 @@ packages: rollup: optional: true dependencies: - '@rollup/pluginutils': 5.0.5(rollup@4.1.4) + '@rollup/pluginutils': 5.0.5(rollup@4.2.0) '@types/resolve': 1.20.2 deepmerge: 4.2.2 is-builtin-module: 3.2.1 is-module: 1.0.0 resolve: 1.22.4 - rollup: 4.1.4 + rollup: 4.2.0 dev: true /@rollup/plugin-replace@5.0.2(rollup@3.29.2): @@ -3563,7 +3563,7 @@ packages: rollup: 3.29.2 dev: true - /@rollup/plugin-typescript@11.1.5(rollup@4.1.4)(tslib@2.6.2)(typescript@5.2.2): + /@rollup/plugin-typescript@11.1.5(rollup@4.2.0)(tslib@2.6.2)(typescript@5.2.2): resolution: {integrity: sha512-rnMHrGBB0IUEv69Q8/JGRD/n4/n6b3nfpufUu26axhUcboUzv/twfZU8fIBbTOphRAe0v8EyxzeDpKXqGHfyDA==} engines: {node: '>=14.0.0'} peerDependencies: @@ -3576,9 +3576,9 @@ packages: tslib: optional: true dependencies: - '@rollup/pluginutils': 5.0.5(rollup@4.1.4) + '@rollup/pluginutils': 5.0.5(rollup@4.2.0) resolve: 1.22.4 - rollup: 4.1.4 + rollup: 4.2.0 tslib: 2.6.2 typescript: 5.2.2 dev: true @@ -3613,7 +3613,7 @@ packages: rollup: 3.29.2 dev: true - /@rollup/pluginutils@5.0.5(rollup@4.1.4): + /@rollup/pluginutils@5.0.5(rollup@4.2.0): resolution: {integrity: sha512-6aEYR910NyP73oHiJglti74iRyOwgFU4x3meH/H8OJx6Ry0j6cOVZ5X/wTvub7G7Ao6qaHBEaNsV3GLJkSsF+Q==} engines: {node: '>=14.0.0'} peerDependencies: @@ -3625,88 +3625,88 @@ packages: '@types/estree': 1.0.2 estree-walker: 2.0.2 picomatch: 2.3.1 - rollup: 4.1.4 + rollup: 4.2.0 dev: true - /@rollup/rollup-android-arm-eabi@4.1.4: - resolution: {integrity: sha512-WlzkuFvpKl6CLFdc3V6ESPt7gq5Vrimd2Yv9IzKXdOpgbH4cdDSS1JLiACX8toygihtH5OlxyQzhXOph7Ovlpw==} + /@rollup/rollup-android-arm-eabi@4.2.0: + resolution: {integrity: sha512-8PlggAxGxavr+pkCNeV1TM2wTb2o+cUWDg9M1cm9nR27Dsn287uZtSLYXoQqQcmq+sYfF7lHfd3sWJJinH9GmA==} cpu: [arm] os: [android] requiresBuild: true optional: true - /@rollup/rollup-android-arm64@4.1.4: - resolution: {integrity: sha512-D1e+ABe56T9Pq2fD+R3ybe1ylCDzu3tY4Qm2Mj24R9wXNCq35+JbFbOpc2yrroO2/tGhTobmEl2Bm5xfE/n8RA==} + /@rollup/rollup-android-arm64@4.2.0: + resolution: {integrity: sha512-+71T85hbMFrJI+zKQULNmSYBeIhru55PYoF/u75MyeN2FcxE4HSPw20319b+FcZ4lWx2Nx/Ql9tN+hoaD3GH/A==} cpu: [arm64] os: [android] requiresBuild: true optional: true - /@rollup/rollup-darwin-arm64@4.1.4: - resolution: {integrity: sha512-7vTYrgEiOrjxnjsgdPB+4i7EMxbVp7XXtS+50GJYj695xYTTEMn3HZVEvgtwjOUkAP/Q4HDejm4fIAjLeAfhtg==} + /@rollup/rollup-darwin-arm64@4.2.0: + resolution: {integrity: sha512-IIIQLuG43QIElT1JZqUP/zqIdiJl4t9U/boa0GZnQTw9m1X0k3mlBuysbgYXeloLT1RozdL7bgw4lpSaI8GOXw==} cpu: [arm64] os: [darwin] requiresBuild: true optional: true - /@rollup/rollup-darwin-x64@4.1.4: - resolution: {integrity: sha512-eGJVZScKSLZkYjhTAESCtbyTBq9SXeW9+TX36ki5gVhDqJtnQ5k0f9F44jNK5RhAMgIj0Ht9+n6HAgH0gUUyWQ==} + /@rollup/rollup-darwin-x64@4.2.0: + resolution: {integrity: sha512-BXcXvnLaea1Xz900omrGJhxHFJfH9jZ0CpJuVsbjjhpniJ6qiLXz3xA8Lekaa4MuhFcJd4f0r+Ky1G4VFbYhWw==} cpu: [x64] os: [darwin] requiresBuild: true optional: true - /@rollup/rollup-linux-arm-gnueabihf@4.1.4: - resolution: {integrity: sha512-HnigYSEg2hOdX1meROecbk++z1nVJDpEofw9V2oWKqOWzTJlJf1UXVbDE6Hg30CapJxZu5ga4fdAQc/gODDkKg==} + /@rollup/rollup-linux-arm-gnueabihf@4.2.0: + resolution: {integrity: sha512-f4K3MKw9Y4AKi4ANGnmPIglr+S+8tO858YrGVuqAHXxJdVghBmz9CPU9kDpOnGvT4g4vg5uNyIFpOOFvffXyMA==} cpu: [arm] os: [linux] requiresBuild: true optional: true - /@rollup/rollup-linux-arm64-gnu@4.1.4: - resolution: {integrity: sha512-TzJ+N2EoTLWkaClV2CUhBlj6ljXofaYzF/R9HXqQ3JCMnCHQZmQnbnZllw7yTDp0OG5whP4gIPozR4QiX+00MQ==} + /@rollup/rollup-linux-arm64-gnu@4.2.0: + resolution: {integrity: sha512-bNsTYQBgp4H7w6cT7FZhesxpcUPahsSIy4NgdZjH1ZwEoZHxi4XKglj+CsSEkhsKi+x6toVvMylhjRKhEMYfnA==} cpu: [arm64] os: [linux] requiresBuild: true optional: true - /@rollup/rollup-linux-arm64-musl@4.1.4: - resolution: {integrity: sha512-aVPmNMdp6Dlo2tWkAduAD/5TL/NT5uor290YvjvFvCv0Q3L7tVdlD8MOGDL+oRSw5XKXKAsDzHhUOPUNPRHVTQ==} + /@rollup/rollup-linux-arm64-musl@4.2.0: + resolution: {integrity: sha512-Jp1NxBJpGLuxRU2ihrQk4IZ+ia5nffobG6sOFUPW5PMYkF0kQtxEbeDuCa69Xif211vUOcxlOnf5IOEIpTEySA==} cpu: [arm64] os: [linux] requiresBuild: true optional: true - /@rollup/rollup-linux-x64-gnu@4.1.4: - resolution: {integrity: sha512-77Fb79ayiDad0grvVsz4/OB55wJRyw9Ao+GdOBA9XywtHpuq5iRbVyHToGxWquYWlEf6WHFQQnFEttsAzboyKg==} + /@rollup/rollup-linux-x64-gnu@4.2.0: + resolution: {integrity: sha512-3p3iRtQmv2aXw+vtKNyZMLOQ+LSRsqArXjKAh2Oj9cqwfIRe7OXvdkOzWfZOIp1F/x5KJzVAxGxnniF4cMbnsQ==} cpu: [x64] os: [linux] requiresBuild: true optional: true - /@rollup/rollup-linux-x64-musl@4.1.4: - resolution: {integrity: sha512-/t6C6niEQTqmQTVTD9TDwUzxG91Mlk69/v0qodIPUnjjB3wR4UA3klg+orR2SU3Ux2Cgf2pWPL9utK80/1ek8g==} + /@rollup/rollup-linux-x64-musl@4.2.0: + resolution: {integrity: sha512-atih7IF/reUZe4LBLC5Izd44hth2tfDIG8LaPp4/cQXdHh9jabcZEvIeRPrpDq0i/Uu487Qu5gl5KwyAnWajnw==} cpu: [x64] os: [linux] requiresBuild: true optional: true - /@rollup/rollup-win32-arm64-msvc@4.1.4: - resolution: {integrity: sha512-ZY5BHHrOPkMbCuGWFNpJH0t18D2LU6GMYKGaqaWTQ3CQOL57Fem4zE941/Ek5pIsVt70HyDXssVEFQXlITI5Gg==} + /@rollup/rollup-win32-arm64-msvc@4.2.0: + resolution: {integrity: sha512-vYxF3tKJeUE4ceYzpNe2p84RXk/fGK30I8frpRfv/MyPStej/mRlojztkN7Jtd1014HHVeq/tYaMBz/3IxkxZw==} cpu: [arm64] os: [win32] requiresBuild: true optional: true - /@rollup/rollup-win32-ia32-msvc@4.1.4: - resolution: {integrity: sha512-XG2mcRfFrJvYyYaQmvCIvgfkaGinfXrpkBuIbJrTl9SaIQ8HumheWTIwkNz2mktCKwZfXHQNpO7RgXLIGQ7HXA==} + /@rollup/rollup-win32-ia32-msvc@4.2.0: + resolution: {integrity: sha512-1LZJ6zpl93SaPQvas618bMFarVwufWTaczH4ESAbFcwiC4OtznA6Ym+hFPyIGaJaGEB8uMWWac0uXGPXOg5FGA==} cpu: [ia32] os: [win32] requiresBuild: true optional: true - /@rollup/rollup-win32-x64-msvc@4.1.4: - resolution: {integrity: sha512-ANFqWYPwkhIqPmXw8vm0GpBEHiPpqcm99jiiAp71DbCSqLDhrtr019C5vhD0Bw4My+LmMvciZq6IsWHqQpl2ZQ==} + /@rollup/rollup-win32-x64-msvc@4.2.0: + resolution: {integrity: sha512-dgQfFdHCNg08nM5zBmqxqc9vrm0DVzhWotpavbPa0j4//MAOKZEB75yGAfzQE9fUJ+4pvM1239Y4IhL8f6sSog==} cpu: [x64] os: [win32] requiresBuild: true @@ -8726,7 +8726,7 @@ packages: '@babel/code-frame': 7.22.13 dev: true - /rollup-plugin-dts@6.1.0(rollup@4.1.4)(typescript@5.2.2): + /rollup-plugin-dts@6.1.0(rollup@4.2.0)(typescript@5.2.2): resolution: {integrity: sha512-ijSCPICkRMDKDLBK9torss07+8dl9UpY9z1N/zTeA1cIqdzMlpkV3MOOC7zukyvQfDyxa1s3Dl2+DeiP/G6DOw==} engines: {node: '>=16'} peerDependencies: @@ -8734,13 +8734,13 @@ packages: typescript: ^4.5 || ^5.0 dependencies: magic-string: 0.30.5 - rollup: 4.1.4 + rollup: 4.2.0 typescript: 5.2.2 optionalDependencies: '@babel/code-frame': 7.22.13 dev: true - /rollup-plugin-license@3.2.0(rollup@4.1.4): + /rollup-plugin-license@3.2.0(rollup@4.2.0): resolution: {integrity: sha512-gLtSOTE3hZ/mDgxg1HvYz87timTpLlyWXnV7OTyYMhn+Esek+xKxAOjtTsYnfMFGtsBWX+hvqC4b2Ct5ABpE6A==} engines: {node: '>=14.0.0'} peerDependencies: @@ -8753,7 +8753,7 @@ packages: mkdirp: 3.0.1 moment: 2.29.3 package-name-regex: 2.0.6 - rollup: 4.1.4 + rollup: 4.2.0 spdx-expression-validate: 2.0.0 spdx-satisfies: 5.0.1 dev: true @@ -8766,23 +8766,23 @@ packages: fsevents: 2.3.3 dev: true - /rollup@4.1.4: - resolution: {integrity: sha512-U8Yk1lQRKqCkDBip/pMYT+IKaN7b7UesK3fLSTuHBoBJacCE+oBqo/dfG/gkUdQNNB2OBmRP98cn2C2bkYZkyw==} + /rollup@4.2.0: + resolution: {integrity: sha512-deaMa9Z+jPVeBD2dKXv+h7EbdKte9++V2potc/ADqvVgEr6DEJ3ia9u0joarjC2lX/ubaCRYz3QVx0TzuVqAJA==} engines: {node: '>=18.0.0', npm: '>=8.0.0'} hasBin: true optionalDependencies: - '@rollup/rollup-android-arm-eabi': 4.1.4 - '@rollup/rollup-android-arm64': 4.1.4 - '@rollup/rollup-darwin-arm64': 4.1.4 - '@rollup/rollup-darwin-x64': 4.1.4 - '@rollup/rollup-linux-arm-gnueabihf': 4.1.4 - '@rollup/rollup-linux-arm64-gnu': 4.1.4 - '@rollup/rollup-linux-arm64-musl': 4.1.4 - '@rollup/rollup-linux-x64-gnu': 4.1.4 - '@rollup/rollup-linux-x64-musl': 4.1.4 - '@rollup/rollup-win32-arm64-msvc': 4.1.4 - '@rollup/rollup-win32-ia32-msvc': 4.1.4 - '@rollup/rollup-win32-x64-msvc': 4.1.4 + '@rollup/rollup-android-arm-eabi': 4.2.0 + '@rollup/rollup-android-arm64': 4.2.0 + '@rollup/rollup-darwin-arm64': 4.2.0 + '@rollup/rollup-darwin-x64': 4.2.0 + '@rollup/rollup-linux-arm-gnueabihf': 4.2.0 + '@rollup/rollup-linux-arm64-gnu': 4.2.0 + '@rollup/rollup-linux-arm64-musl': 4.2.0 + '@rollup/rollup-linux-x64-gnu': 4.2.0 + '@rollup/rollup-linux-x64-musl': 4.2.0 + '@rollup/rollup-win32-arm64-msvc': 4.2.0 + '@rollup/rollup-win32-ia32-msvc': 4.2.0 + '@rollup/rollup-win32-x64-msvc': 4.2.0 fsevents: 2.3.3 /run-parallel@1.2.0: From 0426910c0301861186a668e4a3fba627f1c421d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=20/=20green?= Date: Wed, 1 Nov 2023 00:33:58 +0900 Subject: [PATCH 7/9] chore: revert "feat: show warning to discourage putting process/global to `define` option (#14447)" (#14827) --- packages/vite/src/node/config.ts | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/packages/vite/src/node/config.ts b/packages/vite/src/node/config.ts index d99d135447c045..57015dc4c356b3 100644 --- a/packages/vite/src/node/config.ts +++ b/packages/vite/src/node/config.ts @@ -483,21 +483,6 @@ export async function resolveConfig( customLogger: config.customLogger, }) - let foundDiscouragedVariableName - if ( - (foundDiscouragedVariableName = Object.keys(config.define ?? {}).find((k) => - ['process', 'global'].includes(k), - )) - ) { - logger.warn( - colors.yellow( - `Replacing ${colors.bold( - foundDiscouragedVariableName, - )} using the define option is discouraged. See https://vitejs.dev/config/shared-options.html#define for more details.`, - ), - ) - } - // resolve root const resolvedRoot = normalizePath( config.root ? path.resolve(config.root) : process.cwd(), From 9df01e3d50cd99b9d8e4aa5b51a8242042e559e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=20/=20green?= Date: Wed, 1 Nov 2023 01:45:07 +0900 Subject: [PATCH 8/9] docs: add links to migration guide (#14830) --- docs/guide/migration.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/guide/migration.md b/docs/guide/migration.md index b04e2ac72aaefc..2825ee65184231 100644 --- a/docs/guide/migration.md +++ b/docs/guide/migration.md @@ -13,7 +13,7 @@ Vite is now using Rollup 4 which also brings along its breaking changes, in part - For Vite plugins, `this.resolve` `skipSelf` option is now `true` by default. - For Vite plugins, `this.parse` now only supports the `allowReturnOutsideFunction` option for now. -Read the full breaking changes in [Rollup's release notes](https://github.com/rollup/rollup/releases/tag/v4.0.0) for build-related changes in `build.rollupOptions`. +Read the full breaking changes in [Rollup's release notes](https://github.com/rollup/rollup/releases/tag/v4.0.0) for build-related changes in [`build.rollupOptions`](/config/build-options.md#build-rollupoptions). ## Deprecate CJS Node API @@ -34,7 +34,7 @@ See the [troubleshooting guide](/guide/troubleshooting.html#vite-cjs-node-api-de ## Rework `define` and `import.meta.env.*` replacement strategy -In Vite 4, the `define` and `import.meta.env.*` features use different replacement strategies in dev and build: +In Vite 4, the [`define`](/config/shared-options.md#define) and [`import.meta.env.*`](/guide/env-and-mode.md#env-variables) features use different replacement strategies in dev and build: - In dev, both features are injected as global variables to `globalThis` and `import.meta` respectively. - In build, both features are statically replaced with a regex. @@ -98,11 +98,11 @@ Note that these changes matches the Node.js behaviour, so you can also run the i ### `worker.plugins` is now a function -In Vite 4, `worker.plugins` accepted an array of plugins (`(Plugin | Plugin[])[]`). From Vite 5, it needs to be configured as a function that returns an array of plugins (`() => (Plugin | Plugin[])[]`). This change is required so parallel worker builds run more consistently and predictably. +In Vite 4, [`worker.plugins`](/config/worker-options.md#worker-plugins) accepted an array of plugins (`(Plugin | Plugin[])[]`). From Vite 5, it needs to be configured as a function that returns an array of plugins (`() => (Plugin | Plugin[])[]`). This change is required so parallel worker builds run more consistently and predictably. ### Allow path containing `.` to fallback to index.html -In Vite 4, accessing a path in dev containing `.` did not fallback to index.html even if `appType` is set to `'spa'` (default). From Vite 5, it will fallback to index.html. +In Vite 4, accessing a path in dev containing `.` did not fallback to index.html even if [`appType`](/config/shared-options.md#apptype) is set to `'spa'` (default). From Vite 5, it will fallback to index.html. Note that the browser will no longer show a 404 error message in the console if you point the image path to a non-existent file (e.g. ``). @@ -128,7 +128,7 @@ In Vite 4, the dev and preview servers serve HTML based on its directory structu ### Manifest files are now generated in `.vite` directory by default -In Vite 4, the manifest files (`build.manifest`, `build.ssrManifest`) was generated in the root of `build.outDir` by default. From Vite 5, those will be generated in the `.vite` directory in the `build.outDir` by default. +In Vite 4, the manifest files ([`build.manifest`](/config/build-options.md#build-manifest), [`build.ssrManifest`](/config/build-options.md#build-ssrmanifest)) was generated in the root of [`build.outDir`](/config/build-options.md#build-outdir) by default. From Vite 5, those will be generated in the `.vite` directory in the `build.outDir` by default. ### CLI shortcuts require an additional `Enter` press @@ -138,7 +138,7 @@ This change prevents Vite from swallowing and controlling OS-specific shortcuts, ### Update `experimentalDecorators` and `useDefineForClassFields` TypeScript behaviour -Vite 5 uses esbuild 0.19 and removes the compatibility layer for esbuild 0.18, which changes how `experimentalDecorators` and `useDefineForClassFields` are handled. +Vite 5 uses esbuild 0.19 and removes the compatibility layer for esbuild 0.18, which changes how [`experimentalDecorators`](https://www.typescriptlang.org/tsconfig#experimentalDecorators) and [`useDefineForClassFields`](https://www.typescriptlang.org/tsconfig#useDefineForClassFields) are handled. - **`experimentalDecorators` is not enabled by default** @@ -217,7 +217,7 @@ Also there are other breaking changes which only affect few users. - [[#14723] fix(resolve)!: remove special .mjs handling](https://github.com/vitejs/vite/pull/14723) - In the past, when a library `"exports"` field maps to an `.mjs` file, Vite will still try to match the `"browser"` and `"module"` fields to fix compatibility with certain libraries. This behavior is now removed to align with the exports resolution algorithm. - [[#14733] feat(resolve)!: remove `resolve.browserField`](https://github.com/vitejs/vite/pull/14733) - - `resolve.browserField` has been deprecated since Vite 3 in favour of an updated default of `['browser', 'module', 'jsnext:main', 'jsnext']` for `resolve.mainFields`. + - `resolve.browserField` has been deprecated since Vite 3 in favour of an updated default of `['browser', 'module', 'jsnext:main', 'jsnext']` for [`resolve.mainFields`](/config/shared-options.md#resolve-mainfields). ## Migration from v3 From 9866be0c275c303b7bc79ad39f64ec98183b3f6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=20/=20green?= Date: Wed, 1 Nov 2023 01:51:28 +0900 Subject: [PATCH 9/9] docs: remove boolean from `server.https` (#14832) --- docs/config/server-options.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/config/server-options.md b/docs/config/server-options.md index 8a2e3a17645600..9efdd443fea150 100644 --- a/docs/config/server-options.md +++ b/docs/config/server-options.md @@ -56,7 +56,7 @@ Set to `true` to exit if port is already in use, instead of automatically trying ## server.https -- **Type:** `boolean | https.ServerOptions` +- **Type:** `https.ServerOptions` Enable TLS + HTTP/2. Note this downgrades to TLS only when the [`server.proxy` option](#server-proxy) is also used.