From 1a3b1d73d7babdab6a52a5fb1ef193fd63666877 Mon Sep 17 00:00:00 2001 From: ferdisap <100170686+ferdisap@users.noreply.github.com> Date: Tue, 19 Mar 2024 14:59:17 +0700 Subject: [PATCH 1/9] fix: update client.ts@cleanUrl to accomodate blob protocol (#16182) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 翠 / green --- packages/vite/src/client/client.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vite/src/client/client.ts b/packages/vite/src/client/client.ts index 45c123213..38b632cb9 100644 --- a/packages/vite/src/client/client.ts +++ b/packages/vite/src/client/client.ts @@ -111,7 +111,7 @@ function setupWebSocket( } function cleanUrl(pathname: string): string { - const url = new URL(pathname, location.toString()) + const url = new URL(pathname, 'http://vitejs.dev') url.searchParams.delete('direct') return url.pathname + url.search } From ea480df56d355d978e510ea017924bfd876804be Mon Sep 17 00:00:00 2001 From: Mark Dalgleish Date: Wed, 20 Mar 2024 09:06:34 +1100 Subject: [PATCH 2/9] fix(create-vite): switch to default Remix template (#16203) --- packages/create-vite/src/index.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/create-vite/src/index.ts b/packages/create-vite/src/index.ts index 71d04b00f..ea22e52c2 100755 --- a/packages/create-vite/src/index.ts +++ b/packages/create-vite/src/index.ts @@ -115,8 +115,7 @@ const FRAMEWORKS: Framework[] = [ name: 'custom-remix', display: 'Remix ↗', color: cyan, - customCommand: - 'npm create remix@latest TARGET_DIR -- --template remix-run/remix/templates/vite', + customCommand: 'npm create remix@latest TARGET_DIR', }, ], }, From e4572b8eae561fffdd720686e3ccd001cc5beaf0 Mon Sep 17 00:00:00 2001 From: bluwy Date: Wed, 20 Mar 2024 17:19:29 +0800 Subject: [PATCH 3/9] release: v5.2.0 --- packages/vite/CHANGELOG.md | 10 ++++++++++ packages/vite/package.json | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/vite/CHANGELOG.md b/packages/vite/CHANGELOG.md index c5f6c5a84..d8436ea88 100644 --- a/packages/vite/CHANGELOG.md +++ b/packages/vite/CHANGELOG.md @@ -1,3 +1,13 @@ +## 5.2.0 (2024-03-20) + +* fix: update client.ts@cleanUrl to accomodate blob protocol (#16182) ([1a3b1d7](https://github.com/vitejs/vite/commit/1a3b1d7)), closes [#16182](https://github.com/vitejs/vite/issues/16182) +* fix(assets): avoid splitting `,` inside query parameter of image URI in srcset property (#16081) ([50caf67](https://github.com/vitejs/vite/commit/50caf67)), closes [#16081](https://github.com/vitejs/vite/issues/16081) +* chore(deps): update all non-major dependencies (#16186) ([842643d](https://github.com/vitejs/vite/commit/842643d)), closes [#16186](https://github.com/vitejs/vite/issues/16186) +* perf(transformRequest): fast-path watch and sourcemap handling (#16170) ([de60f1e](https://github.com/vitejs/vite/commit/de60f1e)), closes [#16170](https://github.com/vitejs/vite/issues/16170) +* docs: add `@shikiji/vitepress-twoslash` (#16168) ([6f8a320](https://github.com/vitejs/vite/commit/6f8a320)), closes [#16168](https://github.com/vitejs/vite/issues/16168) + + + ## 5.2.0-beta.1 (2024-03-14) * feat: csp nonce support (#16052) ([1d5eec4](https://github.com/vitejs/vite/commit/1d5eec4)), closes [#16052](https://github.com/vitejs/vite/issues/16052) diff --git a/packages/vite/package.json b/packages/vite/package.json index 12368df31..ef04d1904 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -1,6 +1,6 @@ { "name": "vite", - "version": "5.2.0-beta.1", + "version": "5.2.0", "type": "module", "license": "MIT", "author": "Evan You", From 0a56177272449489921fef5479b7385dc79a8beb Mon Sep 17 00:00:00 2001 From: Leon Fong Date: Wed, 20 Mar 2024 17:36:20 +0800 Subject: [PATCH 4/9] docs: update volar name and remove takeover mode related docs (#16171) Co-authored-by: patak --- packages/create-vite/template-vue-ts/README.md | 15 +++------------ packages/create-vite/template-vue/README.md | 2 +- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/packages/create-vite/template-vue-ts/README.md b/packages/create-vite/template-vue-ts/README.md index ef72fd524..0bfecb08f 100644 --- a/packages/create-vite/template-vue-ts/README.md +++ b/packages/create-vite/template-vue-ts/README.md @@ -2,17 +2,8 @@ This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 ` asset for (const { start, end, url } of scriptUrls) { if (checkPublicFile(url, config)) { - s.update(start, end, partialEncodeURI(toOutputPublicFilePath(url))) + s.update( + start, + end, + partialEncodeURIPath(toOutputPublicFilePath(url)), + ) } else if (!isExcludedUrl(url)) { s.update( start, end, - partialEncodeURI(await urlToBuiltUrl(url, id, config, this)), + partialEncodeURIPath(await urlToBuiltUrl(url, id, config, this)), ) } } @@ -904,7 +909,7 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin { if (chunk) { chunk.viteMetadata!.importedAssets.add(cleanUrl(file)) } - return encodeURI(toOutputAssetFilePath(file)) + postfix + return encodeURIPath(toOutputAssetFilePath(file)) + postfix }) result = result.replace(publicAssetUrlRE, (_, fileHash) => { @@ -912,7 +917,7 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin { getPublicAssetFilename(fileHash, config)!, ) - return encodeURI( + return encodeURIPath( urlCanParse(publicAssetPath) ? publicAssetPath : normalizePath(publicAssetPath), diff --git a/packages/vite/src/node/plugins/importAnalysis.ts b/packages/vite/src/node/plugins/importAnalysis.ts index db8256ec3..4f69d3440 100644 --- a/packages/vite/src/node/plugins/importAnalysis.ts +++ b/packages/vite/src/node/plugins/importAnalysis.ts @@ -40,7 +40,7 @@ import { joinUrlSegments, moduleListContains, normalizePath, - partialEncodeURI, + partialEncodeURIPath, prettifyUrl, removeImportQuery, removeTimestampQuery, @@ -594,7 +594,7 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin { rewriteDone = true } if (!rewriteDone) { - const rewrittenUrl = JSON.stringify(partialEncodeURI(url)) + const rewrittenUrl = JSON.stringify(partialEncodeURIPath(url)) const s = isDynamicImport ? start : start - 1 const e = isDynamicImport ? end : end + 1 str().overwrite(s, e, rewrittenUrl, { diff --git a/packages/vite/src/node/plugins/worker.ts b/packages/vite/src/node/plugins/worker.ts index 0a200cdb7..4094b581a 100644 --- a/packages/vite/src/node/plugins/worker.ts +++ b/packages/vite/src/node/plugins/worker.ts @@ -5,7 +5,13 @@ import type { ResolvedConfig } from '../config' import type { Plugin } from '../plugin' import type { ViteDevServer } from '../server' import { ENV_ENTRY, ENV_PUBLIC_PATH } from '../constants' -import { getHash, injectQuery, prettifyUrl, urlRE } from '../utils' +import { + encodeURIPath, + getHash, + injectQuery, + prettifyUrl, + urlRE, +} from '../utils' import { createToImportMetaURLBasedRelativeRuntime, onRollupWarning, @@ -411,7 +417,7 @@ export function webWorkerPlugin(config: ResolvedConfig): Plugin { ) const replacementString = typeof replacement === 'string' - ? JSON.stringify(encodeURI(replacement)).slice(1, -1) + ? JSON.stringify(encodeURIPath(replacement)).slice(1, -1) : `"+${replacement.runtime}+"` s.update(match.index, match.index + full.length, replacementString) } diff --git a/packages/vite/src/node/utils.ts b/packages/vite/src/node/utils.ts index da754f215..0352cd19e 100644 --- a/packages/vite/src/node/utils.ts +++ b/packages/vite/src/node/utils.ts @@ -1418,9 +1418,20 @@ export function displayTime(time: number): string { } /** - * Like `encodeURI`, but only replacing `%` as `%25`. This is useful for environments + * Encodes the URI path portion (ignores part after ? or #) + */ +export function encodeURIPath(uri: string): string { + const filePath = cleanUrl(uri) + const postfix = filePath !== uri ? uri.slice(filePath.length) : '' + return encodeURI(filePath) + postfix +} + +/** + * Like `encodeURIPath`, but only replacing `%` as `%25`. This is useful for environments * that can handle un-encoded URIs, where `%` is the only ambiguous character. */ -export function partialEncodeURI(uri: string): string { - return uri.replaceAll('%', '%25') +export function partialEncodeURIPath(uri: string): string { + const filePath = cleanUrl(uri) + const postfix = filePath !== uri ? uri.slice(filePath.length) : '' + return filePath.replaceAll('%', '%25') + postfix } From ee4d2bcfed7bc500b9b1dd43bfe9a6cb1c9737bd Mon Sep 17 00:00:00 2001 From: patak Date: Wed, 20 Mar 2024 13:35:40 +0100 Subject: [PATCH 7/9] release: v5.2.1 --- packages/vite/CHANGELOG.md | 6 ++++++ packages/vite/package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/vite/CHANGELOG.md b/packages/vite/CHANGELOG.md index d8436ea88..65f47dff2 100644 --- a/packages/vite/CHANGELOG.md +++ b/packages/vite/CHANGELOG.md @@ -1,3 +1,9 @@ +## 5.2.1 (2024-03-20) + +* fix: encode path uri only (#16212) ([0b2e40b](https://github.com/vitejs/vite/commit/0b2e40b)), closes [#16212](https://github.com/vitejs/vite/issues/16212) + + + ## 5.2.0 (2024-03-20) * fix: update client.ts@cleanUrl to accomodate blob protocol (#16182) ([1a3b1d7](https://github.com/vitejs/vite/commit/1a3b1d7)), closes [#16182](https://github.com/vitejs/vite/issues/16182) diff --git a/packages/vite/package.json b/packages/vite/package.json index ef04d1904..3c6297ae7 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -1,6 +1,6 @@ { "name": "vite", - "version": "5.2.0", + "version": "5.2.1", "type": "module", "license": "MIT", "author": "Evan You", From e4d2d601177c2dd58fe672e2da9d9e487595fbf3 Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Wed, 20 Mar 2024 21:01:58 +0800 Subject: [PATCH 8/9] fix(importAnalysis): skip encode in ssr (#16213) --- packages/vite/src/node/plugins/importAnalysis.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/vite/src/node/plugins/importAnalysis.ts b/packages/vite/src/node/plugins/importAnalysis.ts index 4f69d3440..4c940aa10 100644 --- a/packages/vite/src/node/plugins/importAnalysis.ts +++ b/packages/vite/src/node/plugins/importAnalysis.ts @@ -594,7 +594,9 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin { rewriteDone = true } if (!rewriteDone) { - const rewrittenUrl = JSON.stringify(partialEncodeURIPath(url)) + const rewrittenUrl = JSON.stringify( + ssr ? url : partialEncodeURIPath(url), + ) const s = isDynamicImport ? start : start - 1 const e = isDynamicImport ? end : end + 1 str().overwrite(s, e, rewrittenUrl, { From d44342859a45a295b9497775f8716de83ca1c03d Mon Sep 17 00:00:00 2001 From: bluwy Date: Wed, 20 Mar 2024 21:15:32 +0800 Subject: [PATCH 9/9] release: v5.2.2 --- packages/vite/CHANGELOG.md | 6 ++++++ packages/vite/package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/vite/CHANGELOG.md b/packages/vite/CHANGELOG.md index 65f47dff2..e6b2bc224 100644 --- a/packages/vite/CHANGELOG.md +++ b/packages/vite/CHANGELOG.md @@ -1,3 +1,9 @@ +## 5.2.2 (2024-03-20) + +* fix(importAnalysis): skip encode in ssr (#16213) ([e4d2d60](https://github.com/vitejs/vite/commit/e4d2d60)), closes [#16213](https://github.com/vitejs/vite/issues/16213) + + + ## 5.2.1 (2024-03-20) * fix: encode path uri only (#16212) ([0b2e40b](https://github.com/vitejs/vite/commit/0b2e40b)), closes [#16212](https://github.com/vitejs/vite/issues/16212) diff --git a/packages/vite/package.json b/packages/vite/package.json index 3c6297ae7..9b0b94d8c 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -1,6 +1,6 @@ { "name": "vite", - "version": "5.2.1", + "version": "5.2.2", "type": "module", "license": "MIT", "author": "Evan You",