From 4e18e726e0af5c72b1fb8ffd9ed6e616fc8769e6 Mon Sep 17 00:00:00 2001 From: patak Date: Wed, 26 Oct 2022 15:10:04 +0200 Subject: [PATCH 01/12] release: plugin-vue@3.2.0 --- packages/plugin-vue/CHANGELOG.md | 9 +++++++++ packages/plugin-vue/package.json | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/plugin-vue/CHANGELOG.md b/packages/plugin-vue/CHANGELOG.md index 4c059b05a864f9..bccb81d2e3f4f9 100644 --- a/packages/plugin-vue/CHANGELOG.md +++ b/packages/plugin-vue/CHANGELOG.md @@ -1,3 +1,12 @@ +## 3.2.0 (2022-10-26) + +* chore(deps): update all non-major dependencies (#10393) ([f519423](https://github.com/vitejs/vite/commit/f519423)), closes [#10393](https://github.com/vitejs/vite/issues/10393) +* chore(deps): update all non-major dependencies (#10488) ([15aa827](https://github.com/vitejs/vite/commit/15aa827)), closes [#10488](https://github.com/vitejs/vite/issues/10488) +* fix(plugin-vue): enable ts in template when using tsx in dev mode (#10180) ([a9f9d31](https://github.com/vitejs/vite/commit/a9f9d31)), closes [#10180](https://github.com/vitejs/vite/issues/10180) +* docs: add missing binding in asset import example (#10414) ([d7ac96d](https://github.com/vitejs/vite/commit/d7ac96d)), closes [#10414](https://github.com/vitejs/vite/issues/10414) + + + ## 3.2.0-beta.0 (2022-10-05) * fix(deps): update all non-major dependencies (#10077) ([caf00c8](https://github.com/vitejs/vite/commit/caf00c8)), closes [#10077](https://github.com/vitejs/vite/issues/10077) diff --git a/packages/plugin-vue/package.json b/packages/plugin-vue/package.json index 9f15765e9735fc..49d2d9fca5e6c7 100644 --- a/packages/plugin-vue/package.json +++ b/packages/plugin-vue/package.json @@ -1,6 +1,6 @@ { "name": "@vitejs/plugin-vue", - "version": "3.2.0-beta.0", + "version": "3.2.0", "license": "MIT", "author": "Evan You", "files": [ From afb637fd8146d565fa4b977ee25dbea7da059a65 Mon Sep 17 00:00:00 2001 From: patak Date: Wed, 26 Oct 2022 15:10:52 +0200 Subject: [PATCH 02/12] release: plugin-vue-jsx@2.1.0 --- packages/plugin-vue-jsx/CHANGELOG.md | 6 ++++++ packages/plugin-vue-jsx/package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/plugin-vue-jsx/CHANGELOG.md b/packages/plugin-vue-jsx/CHANGELOG.md index 3293b83a98383f..fe4418c05025ec 100644 --- a/packages/plugin-vue-jsx/CHANGELOG.md +++ b/packages/plugin-vue-jsx/CHANGELOG.md @@ -1,3 +1,9 @@ +## 2.1.0 (2022-10-26) + +* fix(deps): update all non-major dependencies (#10610) ([bb95467](https://github.com/vitejs/vite/commit/bb95467)), closes [#10610](https://github.com/vitejs/vite/issues/10610) + + + ## 2.1.0-beta.0 (2022-10-05) * fix(deps): update all non-major dependencies (#10077) ([caf00c8](https://github.com/vitejs/vite/commit/caf00c8)), closes [#10077](https://github.com/vitejs/vite/issues/10077) diff --git a/packages/plugin-vue-jsx/package.json b/packages/plugin-vue-jsx/package.json index a239fca5298f90..efa81c9877c7bf 100644 --- a/packages/plugin-vue-jsx/package.json +++ b/packages/plugin-vue-jsx/package.json @@ -1,6 +1,6 @@ { "name": "@vitejs/plugin-vue-jsx", - "version": "2.1.0-beta.0", + "version": "2.1.0", "license": "MIT", "author": "Evan You", "files": [ From 972b8ddca78f47ed730aa76dede28f52b23d8f56 Mon Sep 17 00:00:00 2001 From: patak Date: Wed, 26 Oct 2022 15:11:48 +0200 Subject: [PATCH 03/12] release: plugin-react@2.2.0 --- packages/plugin-react/CHANGELOG.md | 8 ++++++++ packages/plugin-react/package.json | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/plugin-react/CHANGELOG.md b/packages/plugin-react/CHANGELOG.md index a6e28f6c9144cb..fa6f5f3a57a6f3 100644 --- a/packages/plugin-react/CHANGELOG.md +++ b/packages/plugin-react/CHANGELOG.md @@ -1,3 +1,11 @@ +## 2.2.0 (2022-10-26) + +* fix(deps): update all non-major dependencies (#10610) ([bb95467](https://github.com/vitejs/vite/commit/bb95467)), closes [#10610](https://github.com/vitejs/vite/issues/10610) +* fix(plugin-react): update `package.json` (#10479) ([7f45eb5](https://github.com/vitejs/vite/commit/7f45eb5)), closes [#10479](https://github.com/vitejs/vite/issues/10479) +* chore(deps): update all non-major dependencies (#10393) ([f519423](https://github.com/vitejs/vite/commit/f519423)), closes [#10393](https://github.com/vitejs/vite/issues/10393) + + + ## 2.2.0-beta.0 (2022-10-05) * fix(deps): update all non-major dependencies (#10077) ([caf00c8](https://github.com/vitejs/vite/commit/caf00c8)), closes [#10077](https://github.com/vitejs/vite/issues/10077) diff --git a/packages/plugin-react/package.json b/packages/plugin-react/package.json index 622788936f1964..273f8c49405782 100644 --- a/packages/plugin-react/package.json +++ b/packages/plugin-react/package.json @@ -1,6 +1,6 @@ { "name": "@vitejs/plugin-react", - "version": "2.2.0-beta.0", + "version": "2.2.0", "license": "MIT", "author": "Evan You", "contributors": [ From 78d438d681fe73a914e7b5b00690c73f25cf3a34 Mon Sep 17 00:00:00 2001 From: patak Date: Wed, 26 Oct 2022 15:12:34 +0200 Subject: [PATCH 04/12] release: plugin-legacy@2.3.0 --- packages/plugin-legacy/CHANGELOG.md | 8 ++++++++ packages/plugin-legacy/package.json | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/plugin-legacy/CHANGELOG.md b/packages/plugin-legacy/CHANGELOG.md index 138560511c4a64..77c9684a7e4f1d 100644 --- a/packages/plugin-legacy/CHANGELOG.md +++ b/packages/plugin-legacy/CHANGELOG.md @@ -1,3 +1,11 @@ +## 2.3.0 (2022-10-26) + +* fix(deps): update all non-major dependencies (#10610) ([bb95467](https://github.com/vitejs/vite/commit/bb95467)), closes [#10610](https://github.com/vitejs/vite/issues/10610) +* chore(deps): update all non-major dependencies (#10393) ([f519423](https://github.com/vitejs/vite/commit/f519423)), closes [#10393](https://github.com/vitejs/vite/issues/10393) +* chore(deps): update all non-major dependencies (#10488) ([15aa827](https://github.com/vitejs/vite/commit/15aa827)), closes [#10488](https://github.com/vitejs/vite/issues/10488) + + + ## 2.3.0-beta.0 (2022-10-05) * fix(deps): update all non-major dependencies (#10160) ([6233c83](https://github.com/vitejs/vite/commit/6233c83)), closes [#10160](https://github.com/vitejs/vite/issues/10160) diff --git a/packages/plugin-legacy/package.json b/packages/plugin-legacy/package.json index dc4dde2906c46d..2452a740b3d512 100644 --- a/packages/plugin-legacy/package.json +++ b/packages/plugin-legacy/package.json @@ -1,6 +1,6 @@ { "name": "@vitejs/plugin-legacy", - "version": "2.3.0-beta.0", + "version": "2.3.0", "license": "MIT", "author": "Evan You", "files": [ From a285da800733545d9b320e2817985d8c3bace802 Mon Sep 17 00:00:00 2001 From: patak Date: Wed, 26 Oct 2022 15:13:39 +0200 Subject: [PATCH 05/12] release: create-vite@3.2.0 --- packages/create-vite/CHANGELOG.md | 18 ++++++++++++++++++ packages/create-vite/package.json | 2 +- .../create-vite/template-lit-ts/package.json | 2 +- packages/create-vite/template-lit/package.json | 2 +- .../template-preact-ts/package.json | 2 +- .../create-vite/template-preact/package.json | 2 +- .../create-vite/template-react-ts/package.json | 4 ++-- .../create-vite/template-react/package.json | 4 ++-- .../template-svelte-ts/package.json | 2 +- .../create-vite/template-svelte/package.json | 2 +- .../template-vanilla-ts/package.json | 2 +- .../create-vite/template-vanilla/package.json | 2 +- .../create-vite/template-vue-ts/package.json | 4 ++-- packages/create-vite/template-vue/package.json | 4 ++-- 14 files changed, 35 insertions(+), 17 deletions(-) diff --git a/packages/create-vite/CHANGELOG.md b/packages/create-vite/CHANGELOG.md index 6a3fa6264561d7..f22d6803f2eb20 100644 --- a/packages/create-vite/CHANGELOG.md +++ b/packages/create-vite/CHANGELOG.md @@ -1,3 +1,21 @@ +## 3.2.0 (2022-10-26) + +* fix(create-vite): remove baseUrl from Svelte configs (#10200) ([9c7a331](https://github.com/vitejs/vite/commit/9c7a331)), closes [#10200](https://github.com/vitejs/vite/issues/10200) +* fix(deps): update all non-major dependencies (#10077) ([caf00c8](https://github.com/vitejs/vite/commit/caf00c8)), closes [#10077](https://github.com/vitejs/vite/issues/10077) +* fix(deps): update all non-major dependencies (#10160) ([6233c83](https://github.com/vitejs/vite/commit/6233c83)), closes [#10160](https://github.com/vitejs/vite/issues/10160) +* fix(deps): update all non-major dependencies (#10316) ([a38b450](https://github.com/vitejs/vite/commit/a38b450)), closes [#10316](https://github.com/vitejs/vite/issues/10316) +* fix(deps): update all non-major dependencies (#10610) ([bb95467](https://github.com/vitejs/vite/commit/bb95467)), closes [#10610](https://github.com/vitejs/vite/issues/10610) +* fix(deps): update all non-major dependencies (#9985) ([855f2f0](https://github.com/vitejs/vite/commit/855f2f0)), closes [#9985](https://github.com/vitejs/vite/issues/9985) +* chore: remove duplicated logic in vanilla template (#10145) ([f29fef5](https://github.com/vitejs/vite/commit/f29fef5)), closes [#10145](https://github.com/vitejs/vite/issues/10145) +* chore(create-vite): remove sourcemap, move --noEmit to tsconfig (#10150) ([414d2ef](https://github.com/vitejs/vite/commit/414d2ef)), closes [#10150](https://github.com/vitejs/vite/issues/10150) +* chore(deps): update all non-major dependencies (#10393) ([f519423](https://github.com/vitejs/vite/commit/f519423)), closes [#10393](https://github.com/vitejs/vite/issues/10393) +* chore(deps): update all non-major dependencies (#10488) ([15aa827](https://github.com/vitejs/vite/commit/15aa827)), closes [#10488](https://github.com/vitejs/vite/issues/10488) +* chore(deps): update dependency vue-tsc to v1 (#10547) ([9d0e0af](https://github.com/vitejs/vite/commit/9d0e0af)), closes [#10547](https://github.com/vitejs/vite/issues/10547) +* feat: Switch to JSX runtime transform in preact-ts template (#10061) ([bf69063](https://github.com/vitejs/vite/commit/bf69063)), closes [#10061](https://github.com/vitejs/vite/issues/10061) +* feat(create-vite): support create-vite-extra (#10214) ([8116cbd](https://github.com/vitejs/vite/commit/8116cbd)), closes [#10214](https://github.com/vitejs/vite/issues/10214) + + + ## 3.1.0 (2022-09-05) * refactor(create-vite): migrate to TypeScript (#9941) ([85fa2c8](https://github.com/vitejs/vite/commit/85fa2c8)), closes [#9941](https://github.com/vitejs/vite/issues/9941) diff --git a/packages/create-vite/package.json b/packages/create-vite/package.json index 5cf1527fe99135..7914ad23aa2b64 100644 --- a/packages/create-vite/package.json +++ b/packages/create-vite/package.json @@ -1,6 +1,6 @@ { "name": "create-vite", - "version": "3.1.0", + "version": "3.2.0", "type": "module", "license": "MIT", "author": "Evan You", diff --git a/packages/create-vite/template-lit-ts/package.json b/packages/create-vite/template-lit-ts/package.json index 1a0a9ba0870e5a..c661a997d013ad 100644 --- a/packages/create-vite/template-lit-ts/package.json +++ b/packages/create-vite/template-lit-ts/package.json @@ -21,6 +21,6 @@ }, "devDependencies": { "typescript": "^4.6.4", - "vite": "^3.1.8" + "vite": "^3.2.0" } } diff --git a/packages/create-vite/template-lit/package.json b/packages/create-vite/template-lit/package.json index c8bcc50fdbeaf2..d6c15733e1cdaf 100644 --- a/packages/create-vite/template-lit/package.json +++ b/packages/create-vite/template-lit/package.json @@ -18,6 +18,6 @@ "lit": "^2.4.0" }, "devDependencies": { - "vite": "^3.1.8" + "vite": "^3.2.0" } } diff --git a/packages/create-vite/template-preact-ts/package.json b/packages/create-vite/template-preact-ts/package.json index 763ea18cf70a91..d57f4d94e519c9 100644 --- a/packages/create-vite/template-preact-ts/package.json +++ b/packages/create-vite/template-preact-ts/package.json @@ -14,6 +14,6 @@ "devDependencies": { "@preact/preset-vite": "^2.4.0", "typescript": "^4.6.4", - "vite": "^3.1.8" + "vite": "^3.2.0" } } diff --git a/packages/create-vite/template-preact/package.json b/packages/create-vite/template-preact/package.json index 0d15984b90f0ac..2c545b2eabe4e5 100644 --- a/packages/create-vite/template-preact/package.json +++ b/packages/create-vite/template-preact/package.json @@ -13,6 +13,6 @@ }, "devDependencies": { "@preact/preset-vite": "^2.4.0", - "vite": "^3.1.8" + "vite": "^3.2.0" } } diff --git a/packages/create-vite/template-react-ts/package.json b/packages/create-vite/template-react-ts/package.json index 2f3e8349f7c8a5..423fe0beefc850 100644 --- a/packages/create-vite/template-react-ts/package.json +++ b/packages/create-vite/template-react-ts/package.json @@ -15,8 +15,8 @@ "devDependencies": { "@types/react": "^18.0.22", "@types/react-dom": "^18.0.7", - "@vitejs/plugin-react": "^2.1.0", + "@vitejs/plugin-react": "^2.2.0", "typescript": "^4.6.4", - "vite": "^3.1.8" + "vite": "^3.2.0" } } diff --git a/packages/create-vite/template-react/package.json b/packages/create-vite/template-react/package.json index 7d8c018c2f82eb..92769e0c36eb35 100644 --- a/packages/create-vite/template-react/package.json +++ b/packages/create-vite/template-react/package.json @@ -15,7 +15,7 @@ "devDependencies": { "@types/react": "^18.0.22", "@types/react-dom": "^18.0.7", - "@vitejs/plugin-react": "^2.1.0", - "vite": "^3.1.8" + "@vitejs/plugin-react": "^2.2.0", + "vite": "^3.2.0" } } diff --git a/packages/create-vite/template-svelte-ts/package.json b/packages/create-vite/template-svelte-ts/package.json index f403ed329612b2..4f3c5fd1549b1d 100644 --- a/packages/create-vite/template-svelte-ts/package.json +++ b/packages/create-vite/template-svelte-ts/package.json @@ -17,6 +17,6 @@ "svelte-preprocess": "^4.10.7", "tslib": "^2.4.0", "typescript": "^4.6.4", - "vite": "^3.1.8" + "vite": "^3.2.0" } } diff --git a/packages/create-vite/template-svelte/package.json b/packages/create-vite/template-svelte/package.json index 17ca61047ae21f..3c803c67e8f63d 100644 --- a/packages/create-vite/template-svelte/package.json +++ b/packages/create-vite/template-svelte/package.json @@ -11,6 +11,6 @@ "devDependencies": { "@sveltejs/vite-plugin-svelte": "^1.1.0", "svelte": "^3.52.0", - "vite": "^3.1.8" + "vite": "^3.2.0" } } diff --git a/packages/create-vite/template-vanilla-ts/package.json b/packages/create-vite/template-vanilla-ts/package.json index 8514ecab8d4efa..86d1c009853615 100644 --- a/packages/create-vite/template-vanilla-ts/package.json +++ b/packages/create-vite/template-vanilla-ts/package.json @@ -10,6 +10,6 @@ }, "devDependencies": { "typescript": "^4.6.4", - "vite": "^3.1.8" + "vite": "^3.2.0" } } diff --git a/packages/create-vite/template-vanilla/package.json b/packages/create-vite/template-vanilla/package.json index 45a6e85f97abdb..248c44a0fb046e 100644 --- a/packages/create-vite/template-vanilla/package.json +++ b/packages/create-vite/template-vanilla/package.json @@ -9,6 +9,6 @@ "preview": "vite preview" }, "devDependencies": { - "vite": "^3.1.8" + "vite": "^3.2.0" } } diff --git a/packages/create-vite/template-vue-ts/package.json b/packages/create-vite/template-vue-ts/package.json index 64927fae1d6d91..1d2d795e2d74d1 100644 --- a/packages/create-vite/template-vue-ts/package.json +++ b/packages/create-vite/template-vue-ts/package.json @@ -12,9 +12,9 @@ "vue": "^3.2.41" }, "devDependencies": { - "@vitejs/plugin-vue": "^3.1.2", + "@vitejs/plugin-vue": "^3.2.0", "typescript": "^4.6.4", - "vite": "^3.1.8", + "vite": "^3.2.0", "vue-tsc": "^1.0.9" } } diff --git a/packages/create-vite/template-vue/package.json b/packages/create-vite/template-vue/package.json index 98211f7e4cf95e..26018b6d131421 100644 --- a/packages/create-vite/template-vue/package.json +++ b/packages/create-vite/template-vue/package.json @@ -12,7 +12,7 @@ "vue": "^3.2.41" }, "devDependencies": { - "@vitejs/plugin-vue": "^3.1.2", - "vite": "^3.1.8" + "@vitejs/plugin-vue": "^3.2.0", + "vite": "^3.2.0" } } From f787a60f46afe856ab0e7b84a32a2d367c1e4fa8 Mon Sep 17 00:00:00 2001 From: patak Date: Wed, 26 Oct 2022 15:26:05 +0200 Subject: [PATCH 06/12] chore: update changelog for 3.2 (#10646) Co-authored-by: Bjorn Lu --- packages/vite/CHANGELOG.md | 138 +++++++++++++++++++++++-------------- 1 file changed, 85 insertions(+), 53 deletions(-) diff --git a/packages/vite/CHANGELOG.md b/packages/vite/CHANGELOG.md index 9d59ddcb5fa2a7..8211f863253182 100644 --- a/packages/vite/CHANGELOG.md +++ b/packages/vite/CHANGELOG.md @@ -1,33 +1,74 @@ ## 3.2.0 (2022-10-26) -* fix: add a warning if css urls not exist during build time (fix #9800) (#10331) ([9f268da](https://github.com/vitejs/vite/commit/9f268da)), closes [#9800](https://github.com/vitejs/vite/issues/9800) [#10331](https://github.com/vitejs/vite/issues/10331) -* fix: increase error overlay z-index (#10603) ([1157941](https://github.com/vitejs/vite/commit/1157941)), closes [#10603](https://github.com/vitejs/vite/issues/10603) -* fix: revert es-module-lexer version (#10614) ([cffe5c9](https://github.com/vitejs/vite/commit/cffe5c9)), closes [#10614](https://github.com/vitejs/vite/issues/10614) -* fix: when the file path is an absolute path, parsing causes parameter loss (#10449) ([df86990](https://github.com/vitejs/vite/commit/df86990)), closes [#10449](https://github.com/vitejs/vite/issues/10449) -* fix(config): resolve build options with fallback (#10645) ([f7021e3](https://github.com/vitejs/vite/commit/f7021e3)), closes [#10645](https://github.com/vitejs/vite/issues/10645) -* fix(deps): update all non-major dependencies (#10610) ([bb95467](https://github.com/vitejs/vite/commit/bb95467)), closes [#10610](https://github.com/vitejs/vite/issues/10610) -* fix(hmr): cannot reload after missing import on server startup (#9534) (#10602) ([ee7c28a](https://github.com/vitejs/vite/commit/ee7c28a)), closes [#9534](https://github.com/vitejs/vite/issues/9534) [#10602](https://github.com/vitejs/vite/issues/10602) -* feat(build): experimental copyPublicDir option (#10550) ([4f4a39f](https://github.com/vitejs/vite/commit/4f4a39f)), closes [#10550](https://github.com/vitejs/vite/issues/10550) -* feat(css): export preprocessCSS API (#10429) ([177b427](https://github.com/vitejs/vite/commit/177b427)), closes [#10429](https://github.com/vitejs/vite/issues/10429) -* feat(preview): support outDir option (#10418) ([15b90b3](https://github.com/vitejs/vite/commit/15b90b3)), closes [#10418](https://github.com/vitejs/vite/issues/10418) +### Main Changes +#### Multiple Entries for Library Mode +Library mode now supports multiple entries: +```js + lib: { + entry: { + primary: 'src/index.ts', + secondary: 'src/secondary.ts' + }, + formats: ['es', 'cjs'] + } + // => primary.es.js, primary.cjs.js, secondary.es.js, secondary.cjs.js +``` +Check out the PR [#7047](https://github.com/vitejs/vite/issues/7047), and the [`build.lib` config docs](https://main.vitejs.dev/config/build-options.html#build-lib) -## 3.2.0-beta.4 (2022-10-24) +#### `build.modulePreload` options -* chore: revert #10196 until Vite 4 (#10574) ([07c0336](https://github.com/vitejs/vite/commit/07c0336)), closes [#10196](https://github.com/vitejs/vite/issues/10196) [#10574](https://github.com/vitejs/vite/issues/10574) -* fix(css): strip BOM (fixes #10043) (#10577) ([e0463bd](https://github.com/vitejs/vite/commit/e0463bd)), closes [#10043](https://github.com/vitejs/vite/issues/10043) [#10577](https://github.com/vitejs/vite/issues/10577) -* fix(ssr): resolve with isRequire true (#10569) ([7b81210](https://github.com/vitejs/vite/commit/7b81210)), closes [#10569](https://github.com/vitejs/vite/issues/10569) +Vite now allows filtering and modifying module preload dependencies for each entry and async chunk. [`experimental.renderBuiltUrl`](https://vitejs.dev/guide/build.html#advanced-base-options) will also get called for preload asset paths. And `build.modulePreload.resolveDependencies` will be called both for JS dynamic imports preload lists and also for HTML preload lists for chunks imported from entry HTML files. Refer to the PR for more context [#9938](https://github.com/vitejs/vite/issues/9938) and check out the [modulePreload config docs](https://vitejs.dev/config/build-options.html#build-modulepreload). Note: `build.modulePreloadPolyfill` is now deprecated, please migrate to `build.modulePreload.polyfill`. +#### Include Duplicate Assets in the Manifest +Laravel and other backends integrations will now get entries for every asset file, even if they have been de-duplicated. See [#9928](https://github.com/vitejs/vite/issues/9928) for more information. -## 3.2.0-beta.3 (2022-10-20) +#### Customizable ErrorOverlay +You can now customize the ErrorOverlay by using [css parts](developer.mozilla.org/en-US/docs/Web/CSS/::part). Check out the PR for more details: [#10234](https://github.com/vitejs/vite/issues/10234). + +### Features + +* feat(build): experimental copyPublicDir option (#10550) ([4f4a39f](https://github.com/vitejs/vite/commit/4f4a39f)), closes [#10550](https://github.com/vitejs/vite/issues/10550) +* feat(css): export preprocessCSS API (#10429) ([177b427](https://github.com/vitejs/vite/commit/177b427)), closes [#10429](https://github.com/vitejs/vite/issues/10429) +* feat(preview): support outDir option (#10418) ([15b90b3](https://github.com/vitejs/vite/commit/15b90b3)), closes [#10418](https://github.com/vitejs/vite/issues/10418) * feat: include line and column in error format (#10529) ([d806c4a](https://github.com/vitejs/vite/commit/d806c4a)), closes [#10529](https://github.com/vitejs/vite/issues/10529) * feat: reuse opening tab in chromium browsers when start dev server (#10485) ([1a2e7a8](https://github.com/vitejs/vite/commit/1a2e7a8)), closes [#10485](https://github.com/vitejs/vite/issues/10485) * feat: update esbuild compilation affecting fields (#10374) ([f542727](https://github.com/vitejs/vite/commit/f542727)), closes [#10374](https://github.com/vitejs/vite/issues/10374) * feat(proxy): Include URL of request in proxy errors (#10508) ([27e2832](https://github.com/vitejs/vite/commit/27e2832)), closes [#10508](https://github.com/vitejs/vite/issues/10508) -* fix: expose server as Http2SecureServer type (#10196) ([f328f61](https://github.com/vitejs/vite/commit/f328f61)), closes [#10196](https://github.com/vitejs/vite/issues/10196) +* refactor: delete dependent pre built proxy modules (#10427) ([b3b388d](https://github.com/vitejs/vite/commit/b3b388d)), closes [#10427](https://github.com/vitejs/vite/issues/10427) +* feat(server): invalidate module with hmr (#10333) ([8328011](https://github.com/vitejs/vite/commit/8328011)), closes [#10333](https://github.com/vitejs/vite/issues/10333) +* feat: build.modulePreload options (#9938) ([e223f84](https://github.com/vitejs/vite/commit/e223f84)), closes [#9938](https://github.com/vitejs/vite/issues/9938) +* feat: customize ErrorOverlay (#10234) ([fe4dc8d](https://github.com/vitejs/vite/commit/fe4dc8d)), closes [#10234](https://github.com/vitejs/vite/issues/10234) +* feat: dynamic import support ?url and ?worker (#8261) ([0cb01ca](https://github.com/vitejs/vite/commit/0cb01ca)), closes [#8261](https://github.com/vitejs/vite/issues/8261) +* feat: include duplicate assets in the manifest (#9928) ([42ecf37](https://github.com/vitejs/vite/commit/42ecf37)), closes [#9928](https://github.com/vitejs/vite/issues/9928) +* feat: support import.meta.hot.invalidate (#10244) ([fb8ab16](https://github.com/vitejs/vite/commit/fb8ab16)), closes [#10244](https://github.com/vitejs/vite/issues/10244) +* feat: support postcss sugarss (#6705) ([8ede2f1](https://github.com/vitejs/vite/commit/8ede2f1)), closes [#6705](https://github.com/vitejs/vite/issues/6705) +* feat(assets): allow `new URL` to resolve package assets (#7837) ([bafccf5](https://github.com/vitejs/vite/commit/bafccf5)), closes [#7837](https://github.com/vitejs/vite/issues/7837) +* feat(client): add data-vite-dev-id attribute to style elements (#10080) ([ea09fde](https://github.com/vitejs/vite/commit/ea09fde)), closes [#10080](https://github.com/vitejs/vite/issues/10080) +* feat(lib): allow multiple entries (#7047) ([65a0fad](https://github.com/vitejs/vite/commit/65a0fad)), closes [#7047](https://github.com/vitejs/vite/issues/7047) +* feat(optimizer): Support bun lockfile format (#10288) ([931d69b](https://github.com/vitejs/vite/commit/931d69b)), closes [#10288](https://github.com/vitejs/vite/issues/10288) +* refactor(types): bundle client types (#9966) ([da632bf](https://github.com/vitejs/vite/commit/da632bf)), closes [#9966](https://github.com/vitejs/vite/issues/9966) +* refactor(types): simplify type exports (#10243) ([291174d](https://github.com/vitejs/vite/commit/291174d)), closes [#10243](https://github.com/vitejs/vite/issues/10243) +* perf: cache compiled glob for `server.fs.deny` (#10044) ([df560b0](https://github.com/vitejs/vite/commit/df560b0)), closes [#10044](https://github.com/vitejs/vite/issues/10044) + +### Bug Fixes + +* fix: add a warning if css urls not exist during build time (fix #9800) (#10331) ([9f268da](https://github.com/vitejs/vite/commit/9f268da)), closes [#9800](https://github.com/vitejs/vite/issues/9800) [#10331](https://github.com/vitejs/vite/issues/10331) +* fix: increase error overlay z-index (#10603) ([1157941](https://github.com/vitejs/vite/commit/1157941)), closes [#10603](https://github.com/vitejs/vite/issues/10603) +* fix: revert es-module-lexer version (#10614) ([cffe5c9](https://github.com/vitejs/vite/commit/cffe5c9)), closes [#10614](https://github.com/vitejs/vite/issues/10614) +* fix: when the file path is an absolute path, parsing causes parameter loss (#10449) ([df86990](https://github.com/vitejs/vite/commit/df86990)), closes [#10449](https://github.com/vitejs/vite/issues/10449) +* fix(config): resolve build options with fallback (#10645) ([f7021e3](https://github.com/vitejs/vite/commit/f7021e3)), closes [#10645](https://github.com/vitejs/vite/issues/10645) +* fix(deps): update all non-major dependencies (#10610) ([bb95467](https://github.com/vitejs/vite/commit/bb95467)), closes [#10610](https://github.com/vitejs/vite/issues/10610) +* fix(hmr): cannot reload after missing import on server startup (#9534) (#10602) ([ee7c28a](https://github.com/vitejs/vite/commit/ee7c28a)), closes [#9534](https://github.com/vitejs/vite/issues/9534) [#10602](https://github.com/vitejs/vite/issues/10602) +* fix(css): strip BOM (fixes #10043) (#10577) ([e0463bd](https://github.com/vitejs/vite/commit/e0463bd)), closes [#10043](https://github.com/vitejs/vite/issues/10043) [#10577](https://github.com/vitejs/vite/issues/10577) +* fix(ssr): resolve with isRequire true (#10569) ([7b81210](https://github.com/vitejs/vite/commit/7b81210)), closes [#10569](https://github.com/vitejs/vite/issues/10569) +* fix: prefer exports when resolving (#10371) ([3259006](https://github.com/vitejs/vite/commit/3259006)), closes [#10371](https://github.com/vitejs/vite/issues/10371) +* fix(config): partial deno support (#10446) ([c4489ea](https://github.com/vitejs/vite/commit/c4489ea)), closes [#10446](https://github.com/vitejs/vite/issues/10446) +* fix(config): skip resolve builtin modules (#10420) ([ecba3f8](https://github.com/vitejs/vite/commit/ecba3f8)), closes [#10420](https://github.com/vitejs/vite/issues/10420) +* fix(ssr): handle parallel hookNodeResolve (#10401) ([1a961d9](https://github.com/vitejs/vite/commit/1a961d9)), closes [#10401](https://github.com/vitejs/vite/issues/10401) * fix(cli): when the user enters the same command (#10474) ([2326f4a](https://github.com/vitejs/vite/commit/2326f4a)), closes [#10474](https://github.com/vitejs/vite/issues/10474) * fix(config): don't use module condition (`import.meta.resolve`) (fixes #10430) (#10528) ([64f19b9](https://github.com/vitejs/vite/commit/64f19b9)), closes [#10430](https://github.com/vitejs/vite/issues/10430) [#10528](https://github.com/vitejs/vite/issues/10528) * fix(css): remove `?direct` in id for postcss process (#10514) ([67e7bf2](https://github.com/vitejs/vite/commit/67e7bf2)), closes [#10514](https://github.com/vitejs/vite/issues/10514) @@ -35,22 +76,6 @@ * fix(legacy): restore entry chunk CSS inlining, reverts #9761 (#10496) ([9cc808e](https://github.com/vitejs/vite/commit/9cc808e)), closes [#9761](https://github.com/vitejs/vite/issues/9761) [#10496](https://github.com/vitejs/vite/issues/10496) * chore: simplify filter plugin code (#10459) ([5d9b810](https://github.com/vitejs/vite/commit/5d9b810)), closes [#10459](https://github.com/vitejs/vite/issues/10459) * chore(deps): update all non-major dependencies (#10488) ([15aa827](https://github.com/vitejs/vite/commit/15aa827)), closes [#10488](https://github.com/vitejs/vite/issues/10488) - - - -## 3.2.0-beta.2 (2022-10-14) - -* refactor: delete dependent pre built proxy modules (#10427) ([b3b388d](https://github.com/vitejs/vite/commit/b3b388d)), closes [#10427](https://github.com/vitejs/vite/issues/10427) -* feat(server): invalidate module with hmr (#10333) ([8328011](https://github.com/vitejs/vite/commit/8328011)), closes [#10333](https://github.com/vitejs/vite/issues/10333) -* fix: prefer exports when resolving (#10371) ([3259006](https://github.com/vitejs/vite/commit/3259006)), closes [#10371](https://github.com/vitejs/vite/issues/10371) -* fix(config): partial deno support (#10446) ([c4489ea](https://github.com/vitejs/vite/commit/c4489ea)), closes [#10446](https://github.com/vitejs/vite/issues/10446) -* fix(config): skip resolve builtin modules (#10420) ([ecba3f8](https://github.com/vitejs/vite/commit/ecba3f8)), closes [#10420](https://github.com/vitejs/vite/issues/10420) -* fix(ssr): handle parallel hookNodeResolve (#10401) ([1a961d9](https://github.com/vitejs/vite/commit/1a961d9)), closes [#10401](https://github.com/vitejs/vite/issues/10401) - - - -## 3.2.0-beta.1 (2022-10-10) - * chore: update magic-string (#10364) ([23c9259](https://github.com/vitejs/vite/commit/23c9259)), closes [#10364](https://github.com/vitejs/vite/issues/10364) * chore(deps): update all non-major dependencies (#10393) ([f519423](https://github.com/vitejs/vite/commit/f519423)), closes [#10393](https://github.com/vitejs/vite/issues/10393) * chore(deps): update dependency @rollup/plugin-alias to v4 (#10394) ([e2b4c8f](https://github.com/vitejs/vite/commit/e2b4c8f)), closes [#10394](https://github.com/vitejs/vite/issues/10394) @@ -59,11 +84,6 @@ * fix(config): don't resolve by module field (#10347) ([cc1c829](https://github.com/vitejs/vite/commit/cc1c829)), closes [#10347](https://github.com/vitejs/vite/issues/10347) * fix(html): handle attrs with prefix (fixes #10337) (#10381) ([7b4d6e8](https://github.com/vitejs/vite/commit/7b4d6e8)), closes [#10337](https://github.com/vitejs/vite/issues/10337) [#10381](https://github.com/vitejs/vite/issues/10381) * fix(ssr): track var as function scope (#10388) ([87b48f9](https://github.com/vitejs/vite/commit/87b48f9)), closes [#10388](https://github.com/vitejs/vite/issues/10388) - - - -## 3.2.0-beta.0 (2022-10-05) - * fix: add module types (#10299) ([0b89dd2](https://github.com/vitejs/vite/commit/0b89dd2)), closes [#10299](https://github.com/vitejs/vite/issues/10299) * fix: css order problem in async chunk (#9949) ([6c7b834](https://github.com/vitejs/vite/commit/6c7b834)), closes [#9949](https://github.com/vitejs/vite/issues/9949) * fix: don't duplicate styles with dynamic import (fix #9967) (#9970) ([65f97bd](https://github.com/vitejs/vite/commit/65f97bd)), closes [#9967](https://github.com/vitejs/vite/issues/9967) [#9970](https://github.com/vitejs/vite/issues/9970) @@ -87,22 +107,34 @@ * fix(ssr): correctly track scope (#10300) ([a60529f](https://github.com/vitejs/vite/commit/a60529f)), closes [#10300](https://github.com/vitejs/vite/issues/10300) * fix(worker): support comment in worker constructor option (#10226) ([66c9058](https://github.com/vitejs/vite/commit/66c9058)), closes [#10226](https://github.com/vitejs/vite/issues/10226) * fix(worker): support trailing comma (#10211) ([0542e7c](https://github.com/vitejs/vite/commit/0542e7c)), closes [#10211](https://github.com/vitejs/vite/issues/10211) -* feat: build.modulePreload options (#9938) ([e223f84](https://github.com/vitejs/vite/commit/e223f84)), closes [#9938](https://github.com/vitejs/vite/issues/9938) -* feat: customize ErrorOverlay (#10234) ([fe4dc8d](https://github.com/vitejs/vite/commit/fe4dc8d)), closes [#10234](https://github.com/vitejs/vite/issues/10234) -* feat: dynamic import support ?url and ?worker (#8261) ([0cb01ca](https://github.com/vitejs/vite/commit/0cb01ca)), closes [#8261](https://github.com/vitejs/vite/issues/8261) -* feat: include duplicate assets in the manifest (#9928) ([42ecf37](https://github.com/vitejs/vite/commit/42ecf37)), closes [#9928](https://github.com/vitejs/vite/issues/9928) -* feat: support import.meta.hot.invalidate (#10244) ([fb8ab16](https://github.com/vitejs/vite/commit/fb8ab16)), closes [#10244](https://github.com/vitejs/vite/issues/10244) -* feat: support postcss sugarss (#6705) ([8ede2f1](https://github.com/vitejs/vite/commit/8ede2f1)), closes [#6705](https://github.com/vitejs/vite/issues/6705) -* feat(assets): allow `new URL` to resolve package assets (#7837) ([bafccf5](https://github.com/vitejs/vite/commit/bafccf5)), closes [#7837](https://github.com/vitejs/vite/issues/7837) -* feat(client): add data-vite-dev-id attribute to style elements (#10080) ([ea09fde](https://github.com/vitejs/vite/commit/ea09fde)), closes [#10080](https://github.com/vitejs/vite/issues/10080) -* feat(lib): allow multiple entries (#7047) ([65a0fad](https://github.com/vitejs/vite/commit/65a0fad)), closes [#7047](https://github.com/vitejs/vite/issues/7047) -* feat(optimizer): Support bun lockfile format (#10288) ([931d69b](https://github.com/vitejs/vite/commit/931d69b)), closes [#10288](https://github.com/vitejs/vite/issues/10288) -* refactor(types): bundle client types (#9966) ([da632bf](https://github.com/vitejs/vite/commit/da632bf)), closes [#9966](https://github.com/vitejs/vite/issues/9966) -* refactor(types): simplify type exports (#10243) ([291174d](https://github.com/vitejs/vite/commit/291174d)), closes [#10243](https://github.com/vitejs/vite/issues/10243) -* chore: remove cacheDir param (#10188) ([6eb374a](https://github.com/vitejs/vite/commit/6eb374a)), closes [#10188](https://github.com/vitejs/vite/issues/10188) -* chore: update type init (#10251) ([ed40a65](https://github.com/vitejs/vite/commit/ed40a65)), closes [#10251](https://github.com/vitejs/vite/issues/10251) -* docs: fix invalid jsdoc comments (#10241) ([9acb839](https://github.com/vitejs/vite/commit/9acb839)), closes [#10241](https://github.com/vitejs/vite/issues/10241) -* perf: cache compiled glob for `server.fs.deny` (#10044) ([df560b0](https://github.com/vitejs/vite/commit/df560b0)), closes [#10044](https://github.com/vitejs/vite/issues/10044) + + +### Previous Changelogs + + +#### [3.2.0-beta.4](https://github.com/vitejs/vite/compare/v3.2.0-beta.3....v3.2.0-beta.4) (2022-10-24) + +See [3.2.0-beta.4 changelog](https://github.com/vitejs/vite/blob/v3.2.0-beta.4/packages/vite/CHANGELOG.md) + + +#### [3.2.0-beta.3](https://github.com/vitejs/vite/compare/v3.2.0-beta.2...v3.2.0-beta.3) (2022-10-20) + +See [3.2.0-beta.3 changelog](https://github.com/vitejs/vite/blob/v3.2.0-beta.4/packages/vite/CHANGELOG.md) + + +#### [3.2.0-beta.2](https://github.com/vitejs/vite/compare/v3.2.0-beta.1...v3.2.0-beta.2) (2022-10-14) + +See [3.2.0-beta.2 changelog](https://github.com/vitejs/vite/blob/v3.2.0-beta.4/packages/vite/CHANGELOG.md) + + +#### [3.2.0-beta.1](https://github.com/vitejs/vite/compare/v3.2.0-beta.0...v3.2.0-beta.1) (2022-10-10) + +See [3.2.0-beta.1 changelog](https://github.com/vitejs/vite/blob/v3.2.0-beta.4/packages/vite/CHANGELOG.md) + + +#### [3.2.0-beta.0](https://github.com/vitejs/vite/compare/v3.1.3...v3.2.0-beta.0) (2022-10-05) + +See [3.2.0-beta.0 changelog](https://github.com/vitejs/vite/blob/v3.2.0-beta.4/packages/vite/CHANGELOG.md) From 675bf07a093c2af5c928bdd1a8458dc235cc442d Mon Sep 17 00:00:00 2001 From: Ben McCann <322311+benmccann@users.noreply.github.com> Date: Thu, 27 Oct 2022 09:24:26 -0700 Subject: [PATCH 07/12] chore: join URL segments more safely (#10590) --- packages/vite/src/node/build.ts | 10 ++++++++-- packages/vite/src/node/plugins/asset.ts | 9 ++++----- packages/vite/src/node/plugins/css.ts | 8 ++++---- packages/vite/src/node/server/index.ts | 7 +++---- packages/vite/src/node/server/middlewares/base.ts | 9 +++++---- .../vite/src/node/server/middlewares/indexHtml.ts | 6 ++++-- packages/vite/src/node/ssr/ssrManifestPlugin.ts | 10 +++++----- packages/vite/src/node/utils.ts | 13 +++++++++++++ 8 files changed, 46 insertions(+), 26 deletions(-) diff --git a/packages/vite/src/node/build.ts b/packages/vite/src/node/build.ts index 65563735927d0f..fe147c1cd1b48d 100644 --- a/packages/vite/src/node/build.ts +++ b/packages/vite/src/node/build.ts @@ -27,7 +27,13 @@ import { isDepsOptimizerEnabled, resolveConfig } from './config' import { buildReporterPlugin } from './plugins/reporter' import { buildEsbuildPlugin } from './plugins/esbuild' import { terserPlugin } from './plugins/terser' -import { copyDir, emptyDir, lookupFile, normalizePath } from './utils' +import { + copyDir, + emptyDir, + joinUrlSegments, + lookupFile, + normalizePath +} from './utils' import { manifestPlugin } from './plugins/manifest' import type { Logger } from './logger' import { dataURIPlugin } from './plugins/dataUri' @@ -1071,7 +1077,7 @@ export function toOutputFilePathInJS( if (relative && !config.build.ssr) { return toRelative(filename, hostId) } - return config.base + filename + return joinUrlSegments(config.base, filename) } export function createToImportMetaURLBasedRelativeRuntime( diff --git a/packages/vite/src/node/plugins/asset.ts b/packages/vite/src/node/plugins/asset.ts index a7a8f2554bf0a1..8a74736715bd9c 100644 --- a/packages/vite/src/node/plugins/asset.ts +++ b/packages/vite/src/node/plugins/asset.ts @@ -19,7 +19,7 @@ import { } from '../build' import type { Plugin } from '../plugin' import type { ResolvedConfig } from '../config' -import { cleanUrl, getHash, normalizePath } from '../utils' +import { cleanUrl, getHash, joinUrlSegments, normalizePath } from '../utils' import { FS_PREFIX } from '../constants' export const assetUrlRE = /__VITE_ASSET__([a-z\d]{8})__(?:\$_(.*?)__)?/g @@ -249,9 +249,8 @@ function fileToDevUrl(id: string, config: ResolvedConfig) { // (this is special handled by the serve static middleware rtn = path.posix.join(FS_PREFIX + id) } - const origin = config.server?.origin ?? '' - const devBase = config.base - return origin + devBase + rtn.replace(/^\//, '') + const base = joinUrlSegments(config.server?.origin ?? '', config.base) + return joinUrlSegments(base, rtn.replace(/^\//, '')) } export function getAssetFilename( @@ -396,7 +395,7 @@ export function publicFileToBuiltUrl( ): string { if (config.command !== 'build') { // We don't need relative base or renderBuiltUrl support during dev - return config.base + url.slice(1) + return joinUrlSegments(config.base, url) } const hash = getHash(url) let cache = publicAssetUrlCache.get(config) diff --git a/packages/vite/src/node/plugins/css.ts b/packages/vite/src/node/plugins/css.ts index 09b70bbb0391aa..ad46e5ba738f37 100644 --- a/packages/vite/src/node/plugins/css.ts +++ b/packages/vite/src/node/plugins/css.ts @@ -39,6 +39,7 @@ import { isDataUrl, isExternalUrl, isObject, + joinUrlSegments, normalizePath, parseRequest, processSrcSet, @@ -211,7 +212,7 @@ export function cssPlugin(config: ResolvedConfig): Plugin { if (encodePublicUrlsInCSS(config)) { return publicFileToBuiltUrl(url, config) } else { - return config.base + url.slice(1) + return joinUrlSegments(config.base, url) } } const resolved = await resolveUrl(url, importer) @@ -249,7 +250,6 @@ export function cssPlugin(config: ResolvedConfig): Plugin { // server only logic for handling CSS @import dependency hmr const { moduleGraph } = server const thisModule = moduleGraph.getModuleById(id) - const devBase = config.base if (thisModule) { // CSS modules cannot self-accept since it exports values const isSelfAccepting = @@ -258,6 +258,7 @@ export function cssPlugin(config: ResolvedConfig): Plugin { // record deps in the module graph so edits to @import css can trigger // main import to hot update const depModules = new Set() + const devBase = config.base for (const file of deps) { depModules.add( isCSSRequest(file) @@ -387,10 +388,9 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin { } const cssContent = await getContentWithSourcemap(css) - const devBase = config.base const code = [ `import { updateStyle as __vite__updateStyle, removeStyle as __vite__removeStyle } from ${JSON.stringify( - path.posix.join(devBase, CLIENT_PUBLIC_PATH) + path.posix.join(config.base, CLIENT_PUBLIC_PATH) )}`, `const __vite__id = ${JSON.stringify(id)}`, `const __vite__css = ${JSON.stringify(cssContent)}`, diff --git a/packages/vite/src/node/server/index.ts b/packages/vite/src/node/server/index.ts index 5e8296e5ad3aad..7ea1d846183bb5 100644 --- a/packages/vite/src/node/server/index.ts +++ b/packages/vite/src/node/server/index.ts @@ -547,8 +547,7 @@ export async function createServer( } // base - const devBase = config.base - if (devBase !== '/') { + if (config.base !== '/') { middlewares.use(baseMiddleware(server)) } @@ -652,7 +651,6 @@ async function startServer( const protocol = options.https ? 'https' : 'http' const info = server.config.logger.info - const devBase = server.config.base const serverPort = await httpServerStart(httpServer, { port, @@ -681,7 +679,8 @@ async function startServer( } if (options.open && !isRestart) { - const path = typeof options.open === 'string' ? options.open : devBase + const path = + typeof options.open === 'string' ? options.open : server.config.base openBrowser( path.startsWith('http') ? path diff --git a/packages/vite/src/node/server/middlewares/base.ts b/packages/vite/src/node/server/middlewares/base.ts index 27960f900b44b7..93d7b4950323d9 100644 --- a/packages/vite/src/node/server/middlewares/base.ts +++ b/packages/vite/src/node/server/middlewares/base.ts @@ -1,12 +1,13 @@ import type { Connect } from 'dep-types/connect' import type { ViteDevServer } from '..' +import { joinUrlSegments } from '../../utils' // this middleware is only active when (config.base !== '/') export function baseMiddleware({ config }: ViteDevServer): Connect.NextHandleFunction { - const devBase = config.base + const devBase = config.base.endsWith('/') ? config.base : config.base + '/' // Keep the named function. The name is visible in debug logs via `DEBUG=connect:dispatcher ...` return function viteBaseMiddleware(req, res, next) { @@ -29,18 +30,18 @@ export function baseMiddleware({ if (path === '/' || path === '/index.html') { // redirect root visit to based url with search and hash res.writeHead(302, { - Location: devBase + (parsed.search || '') + (parsed.hash || '') + Location: config.base + (parsed.search || '') + (parsed.hash || '') }) res.end() return } else if (req.headers.accept?.includes('text/html')) { // non-based page visit - const redirectPath = devBase + url.slice(1) + const redirectPath = joinUrlSegments(config.base, url) res.writeHead(404, { 'Content-Type': 'text/html' }) res.end( - `The server is configured with a public base URL of ${devBase} - ` + + `The server is configured with a public base URL of ${config.base} - ` + `did you mean to visit ${redirectPath} instead?` ) return diff --git a/packages/vite/src/node/server/middlewares/indexHtml.ts b/packages/vite/src/node/server/middlewares/indexHtml.ts index 326281b853f079..3c57832db0fd20 100644 --- a/packages/vite/src/node/server/middlewares/indexHtml.ts +++ b/packages/vite/src/node/server/middlewares/indexHtml.ts @@ -26,6 +26,7 @@ import { ensureWatchedFile, fsPathFromId, injectQuery, + joinUrlSegments, normalizePath, processSrcSetSync, wrapId @@ -93,7 +94,8 @@ const processNodeUrl = ( const devBase = config.base if (startsWithSingleSlashRE.test(url)) { // prefix with base (dev only, base is never relative) - overwriteAttrValue(s, sourceCodeLocation, devBase + url.slice(1)) + const fullUrl = joinUrlSegments(devBase, url) + overwriteAttrValue(s, sourceCodeLocation, fullUrl) } else if ( url.startsWith('.') && originalUrl && @@ -132,7 +134,7 @@ const devHtmlHook: IndexHtmlTransformHook = async ( const trailingSlash = htmlPath.endsWith('/') if (!trailingSlash && fs.existsSync(filename)) { proxyModulePath = htmlPath - proxyModuleUrl = base + htmlPath.slice(1) + proxyModuleUrl = joinUrlSegments(base, htmlPath) } else { // There are users of vite.transformIndexHtml calling it with url '/' // for SSR integrations #7993, filename is root for this case diff --git a/packages/vite/src/node/ssr/ssrManifestPlugin.ts b/packages/vite/src/node/ssr/ssrManifestPlugin.ts index 1cc2d79d770fe8..9a68b5ea22afe5 100644 --- a/packages/vite/src/node/ssr/ssrManifestPlugin.ts +++ b/packages/vite/src/node/ssr/ssrManifestPlugin.ts @@ -5,7 +5,7 @@ import type { OutputChunk } from 'rollup' import type { ResolvedConfig } from '..' import type { Plugin } from '../plugin' import { preloadMethod } from '../plugins/importAnalysisBuild' -import { normalizePath } from '../utils' +import { joinUrlSegments, normalizePath } from '../utils' export function ssrManifestPlugin(config: ResolvedConfig): Plugin { // module id => preload assets mapping @@ -23,15 +23,15 @@ export function ssrManifestPlugin(config: ResolvedConfig): Plugin { const mappedChunks = ssrManifest[normalizedId] ?? (ssrManifest[normalizedId] = []) if (!chunk.isEntry) { - mappedChunks.push(base + chunk.fileName) + mappedChunks.push(joinUrlSegments(base, chunk.fileName)) // tags for entry chunks are already generated in static HTML, // so we only need to record info for non-entry chunks. chunk.viteMetadata.importedCss.forEach((file) => { - mappedChunks.push(base + file) + mappedChunks.push(joinUrlSegments(base, file)) }) } chunk.viteMetadata.importedAssets.forEach((file) => { - mappedChunks.push(base + file) + mappedChunks.push(joinUrlSegments(base, file)) }) } if (chunk.code.includes(preloadMethod)) { @@ -59,7 +59,7 @@ export function ssrManifestPlugin(config: ResolvedConfig): Plugin { const chunk = bundle[filename] as OutputChunk | undefined if (chunk) { chunk.viteMetadata.importedCss.forEach((file) => { - deps.push(join(base, file)) // TODO:base + deps.push(joinUrlSegments(base, file)) // TODO:base }) chunk.imports.forEach(addDeps) } diff --git a/packages/vite/src/node/utils.ts b/packages/vite/src/node/utils.ts index 5e7081813a8c06..bead9cee598504 100644 --- a/packages/vite/src/node/utils.ts +++ b/packages/vite/src/node/utils.ts @@ -1191,3 +1191,16 @@ export const isNonDriveRelativeAbsolutePath = (p: string): boolean => { if (!isWindows) return p.startsWith('/') return windowsDrivePathPrefixRE.test(p) } + +export function joinUrlSegments(a: string, b: string): string { + if (!a || !b) { + return a || b || '' + } + if (a.endsWith('/')) { + a = a.substring(0, a.length - 1) + } + if (!b.startsWith('/')) { + b = '/' + b + } + return a + b +} From b823fd6ce35ccc9c6acd387bbd9bb3a891063c91 Mon Sep 17 00:00:00 2001 From: Abdellah Alaoui Solaimani Date: Fri, 28 Oct 2022 09:54:33 +0300 Subject: [PATCH 08/12] feat: Add support for imba in html scripts (#10679) --- packages/vite/src/node/optimizer/esbuildDepPlugin.ts | 1 + packages/vite/src/node/optimizer/scan.ts | 2 +- packages/vite/src/node/utils.ts | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/vite/src/node/optimizer/esbuildDepPlugin.ts b/packages/vite/src/node/optimizer/esbuildDepPlugin.ts index c90ea58ec73b42..463cc53e521cec 100644 --- a/packages/vite/src/node/optimizer/esbuildDepPlugin.ts +++ b/packages/vite/src/node/optimizer/esbuildDepPlugin.ts @@ -34,6 +34,7 @@ const externalTypes = [ 'svelte', 'marko', 'astro', + 'imba', // JSX/TSX may be configured to be compiled differently from how esbuild // handles it by default, so exclude them as well 'jsx', diff --git a/packages/vite/src/node/optimizer/scan.ts b/packages/vite/src/node/optimizer/scan.ts index e600e7ff69f96f..cc542b5ecb1e7e 100644 --- a/packages/vite/src/node/optimizer/scan.ts +++ b/packages/vite/src/node/optimizer/scan.ts @@ -29,7 +29,7 @@ type ResolveIdOptions = Parameters[2] const debug = createDebugger('vite:deps') -const htmlTypesRE = /\.(html|vue|svelte|astro)$/ +const htmlTypesRE = /\.(html|vue|svelte|astro|imba)$/ // A simple regex to detect import sources. This is only used on //