From 2728a31b28b0c0335ce3aa9ce789c4389973d435 Mon Sep 17 00:00:00 2001 From: patak Date: Mon, 23 Oct 2023 09:12:10 +0200 Subject: [PATCH 1/5] docs: port 4.4.10 to 4.5 changelog to main (#14732) --- packages/vite/CHANGELOG.md | 39 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/packages/vite/CHANGELOG.md b/packages/vite/CHANGELOG.md index b52db1df561b2e..bbcb070082a62b 100644 --- a/packages/vite/CHANGELOG.md +++ b/packages/vite/CHANGELOG.md @@ -201,6 +201,45 @@ Learn more at the [Vite 5 Migration guide](https://main.vitejs.dev/guide/migrati +## 4.5.0 (2023-10-18) + +* feat: backport mdx as known js source (#14560) (#14670) ([45595ef](https://github.com/vitejs/vite/commit/45595ef)), closes [#14560](https://github.com/vitejs/vite/issues/14560) [#14670](https://github.com/vitejs/vite/issues/14670) +* feat: scan .marko files (#14669) ([ed7bdc5](https://github.com/vitejs/vite/commit/ed7bdc5)), closes [#14669](https://github.com/vitejs/vite/issues/14669) +* feat(ssr): backport ssr.resolve.conditions and ssr.resolve.externalConditions (#14498) (#14668) ([520139c](https://github.com/vitejs/vite/commit/520139c)), closes [#14498](https://github.com/vitejs/vite/issues/14498) [#14668](https://github.com/vitejs/vite/issues/14668) + + + +## 4.4.11 (2023-10-05) + +* revert: "fix: use string manipulation instead of regex to inject esbuild helpers ([54e1275](https://github.com/vitejs/vite/commit/54e1275)), closes [#14094](https://github.com/vitejs/vite/issues/14094) + + + +## 4.4.10 (2023-10-03) + +* fix: add source map to Web Workers (fix #14216) (#14217) ([df6f32f](https://github.com/vitejs/vite/commit/df6f32f)), closes [#14216](https://github.com/vitejs/vite/issues/14216) [#14217](https://github.com/vitejs/vite/issues/14217) +* fix: handle errors during `hasWorkspacePackageJSON` function (#14394) ([6f6e5de](https://github.com/vitejs/vite/commit/6f6e5de)), closes [#14394](https://github.com/vitejs/vite/issues/14394) +* fix: handle sourcemap correctly when multiple line import exists (#14232) ([218861f](https://github.com/vitejs/vite/commit/218861f)), closes [#14232](https://github.com/vitejs/vite/issues/14232) +* fix: if host is specified check whether it is valid (#14013) ([b1b816a](https://github.com/vitejs/vite/commit/b1b816a)), closes [#14013](https://github.com/vitejs/vite/issues/14013) +* fix: include `vite/types/*` in exports field (#14296) ([40e99a1](https://github.com/vitejs/vite/commit/40e99a1)), closes [#14296](https://github.com/vitejs/vite/issues/14296) +* fix: initWasm options should be optional (#14152) ([119c074](https://github.com/vitejs/vite/commit/119c074)), closes [#14152](https://github.com/vitejs/vite/issues/14152) +* fix: restore builtins list ([f8b9adb](https://github.com/vitejs/vite/commit/f8b9adb)) +* fix: use string manipulation instead of regex to inject esbuild helpers (#14094) ([128ad8f](https://github.com/vitejs/vite/commit/128ad8f)), closes [#14094](https://github.com/vitejs/vite/issues/14094) +* fix: ws never connects after restarting server if server.hmr.server is set (#14127) ([441642e](https://github.com/vitejs/vite/commit/441642e)), closes [#14127](https://github.com/vitejs/vite/issues/14127) +* fix(analysis): warnings for dynamic imports that use static template literals (#14458) ([0c6d289](https://github.com/vitejs/vite/commit/0c6d289)), closes [#14458](https://github.com/vitejs/vite/issues/14458) +* fix(cli): convert special base (#14283) ([d4bc0fb](https://github.com/vitejs/vite/commit/d4bc0fb)), closes [#14283](https://github.com/vitejs/vite/issues/14283) +* fix(css): remove pure css chunk sourcemap (#14290) ([cd7e033](https://github.com/vitejs/vite/commit/cd7e033)), closes [#14290](https://github.com/vitejs/vite/issues/14290) +* fix(css): reset render cache on renderStart (#14326) ([d334b3d](https://github.com/vitejs/vite/commit/d334b3d)), closes [#14326](https://github.com/vitejs/vite/issues/14326) +* fix(glob): trigger HMR for glob in a package (#14117) ([0f582bf](https://github.com/vitejs/vite/commit/0f582bf)), closes [#14117](https://github.com/vitejs/vite/issues/14117) +* fix(import-analysis): preserve importedUrls import order (#14465) ([269aa43](https://github.com/vitejs/vite/commit/269aa43)), closes [#14465](https://github.com/vitejs/vite/issues/14465) +* fix(manifest): preserve pure css chunk assets (#14297) ([3d63ae6](https://github.com/vitejs/vite/commit/3d63ae6)), closes [#14297](https://github.com/vitejs/vite/issues/14297) +* fix(optimizer): define crawlDeps after scanProcessing and optimizationResult are complete (fix #1428 ([fcaf749](https://github.com/vitejs/vite/commit/fcaf749)), closes [#14284](https://github.com/vitejs/vite/issues/14284) [#14285](https://github.com/vitejs/vite/issues/14285) +* fix(resolve): support submodules of optional peer deps (#14489) ([104971d](https://github.com/vitejs/vite/commit/104971d)), closes [#14489](https://github.com/vitejs/vite/issues/14489) +* fix(vite): precisely check if files are in dirs (#14241) ([c4758d1](https://github.com/vitejs/vite/commit/c4758d1)), closes [#14241](https://github.com/vitejs/vite/issues/14241) +* feat: improve deno and bun support (#14379) ([8bc1f9d](https://github.com/vitejs/vite/commit/8bc1f9d)), closes [#14379](https://github.com/vitejs/vite/issues/14379) + + + ## 4.4.9 (2023-08-07) * chore: fix eslint warnings (#14031) ([4021a0e](https://github.com/vitejs/vite/commit/4021a0e)), closes [#14031](https://github.com/vitejs/vite/issues/14031) From d520388fca12f86df9dcc31e38cea76f180a2ff0 Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Mon, 23 Oct 2023 15:59:34 +0800 Subject: [PATCH 2/5] fix(resolve): make directory package.json check best effort (#14626) --- packages/vite/src/node/plugins/resolve.ts | 10 +++++++-- playground/resolve/__tests__/resolve.spec.ts | 22 +++++++++++++++++++- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/packages/vite/src/node/plugins/resolve.ts b/packages/vite/src/node/plugins/resolve.ts index 3abb5d87be2a23..7d9a1cc5093b51 100644 --- a/packages/vite/src/node/plugins/resolve.ts +++ b/packages/vite/src/node/plugins/resolve.ts @@ -53,6 +53,8 @@ import { const normalizedClientEntry = normalizePath(CLIENT_ENTRY) const normalizedEnvEntry = normalizePath(ENV_ENTRY) +const ERR_RESOLVE_PACKAGE_ENTRY_FAIL = 'ERR_RESOLVE_PACKAGE_ENTRY_FAIL' + // special id for paths marked with browser: false // https://github.com/defunctzombie/package-browser-field-spec#ignore-a-module export const browserExternalId = '__vite-browser-external' @@ -643,7 +645,9 @@ function tryCleanFsResolve( return resolvePackageEntry(dirPath, pkg, targetWeb, options) } } catch (e) { - if (e.code !== 'ENOENT') throw e + // This check is best effort, so if an entry is not found, skip error for now + if (e.code !== ERR_RESOLVE_PACKAGE_ENTRY_FAIL && e.code !== 'ENOENT') + throw e } } @@ -1095,11 +1099,13 @@ export function resolvePackageEntry( } function packageEntryFailure(id: string, details?: string) { - throw new Error( + const err: any = new Error( `Failed to resolve entry for package "${id}". ` + `The package may have incorrect main/module/exports specified in its package.json` + (details ? ': ' + details : '.'), ) + err.code = ERR_RESOLVE_PACKAGE_ENTRY_FAIL + throw err } function resolveExportsOrImports( diff --git a/playground/resolve/__tests__/resolve.spec.ts b/playground/resolve/__tests__/resolve.spec.ts index 4a753149552bf2..d5067698e13713 100644 --- a/playground/resolve/__tests__/resolve.spec.ts +++ b/playground/resolve/__tests__/resolve.spec.ts @@ -1,7 +1,8 @@ import fs from 'node:fs' import path from 'node:path' +import { fileURLToPath } from 'node:url' import { expect, test } from 'vitest' -import { isBuild, isWindows, page, testDir } from '~utils' +import { isBuild, isWindows, page, testDir, viteTestUrl } from '~utils' test('bom import', async () => { expect(await page.textContent('.utf8-bom')).toMatch('[success]') @@ -202,6 +203,25 @@ test('Resolving from other package with imports field', async () => { expect(await page.textContent('.imports-pkg-slash')).toMatch('[success]') }) +test('Resolve doesnt interrupt page request with trailing query and .css', async () => { + await page.goto(viteTestUrl + '/?test.css') + expect(await page.locator('vite-error-overlay').count()).toBe(0) + expect(await page.textContent('h1')).toBe('Resolve') +}) + +test.runIf(!isWindows)( + 'Resolve doesnt interrupt page request that clashes with local project package.json', + async () => { + // Sometimes request path may point to a different project's package.json, but for testing + // we point to Vite's own monorepo which always exists, and the package.json is not a library + const pathToViteMonorepoRoot = new URL('../../../', import.meta.url) + const urlPath = fileURLToPath(pathToViteMonorepoRoot).replace(/\/$/, '') + await page.goto(viteTestUrl + urlPath) + expect(await page.locator('vite-error-overlay').count()).toBe(0) + expect(await page.textContent('h1')).toBe('Resolve') + }, +) + test.runIf(isBuild)('public dir is not copied', async () => { expect( fs.existsSync(path.resolve(testDir, 'dist/should-not-be-copied')), From cc6319f3af32498b041a1830f7c35fcf22be5a53 Mon Sep 17 00:00:00 2001 From: patak Date: Mon, 23 Oct 2023 10:35:41 +0200 Subject: [PATCH 3/5] docs: remove ViteConf 23 CTA and add a link in Resources (#14736) --- docs/.vitepress/config.ts | 4 ++ .../theme/components/AsideSponsors.vue | 63 ------------------- docs/index.md | 3 - 3 files changed, 4 insertions(+), 66 deletions(-) diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index 9e1ca82dc49a47..00d962b1ecf772 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -152,6 +152,10 @@ export default defineConfig({ text: 'Awesome Vite', link: 'https://github.com/vitejs/awesome-vite', }, + { + text: 'ViteConf', + link: 'https://viteconf.org', + }, { text: 'DEV Community', link: 'https://dev.to/t/vite', diff --git a/docs/.vitepress/theme/components/AsideSponsors.vue b/docs/.vitepress/theme/components/AsideSponsors.vue index dcaf44921ae737..90e6addab959a5 100644 --- a/docs/.vitepress/theme/components/AsideSponsors.vue +++ b/docs/.vitepress/theme/components/AsideSponsors.vue @@ -18,68 +18,5 @@ const sponsors = computed(() => { - - diff --git a/docs/index.md b/docs/index.md index fb683307bd6f4b..bdf716bc3d20a7 100644 --- a/docs/index.md +++ b/docs/index.md @@ -21,9 +21,6 @@ hero: - theme: alt text: View on GitHub link: https://github.com/vitejs/vite - - theme: brand - text: 🎉 ViteConf 23! - link: https://viteconf.org/23 features: - icon: 💡 From 2141d3132d297c6dc3ad5698ef508fd08f5229a9 Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Tue, 24 Oct 2023 00:05:39 +0800 Subject: [PATCH 4/5] fix(resolve)!: remove special .mjs handling (#14723) --- docs/guide/migration.md | 2 ++ packages/vite/src/node/plugins/resolve.ts | 16 +++------------- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/docs/guide/migration.md b/docs/guide/migration.md index 65d8b4e78c6101..99e39a4e37fa81 100644 --- a/docs/guide/migration.md +++ b/docs/guide/migration.md @@ -133,6 +133,8 @@ Also there are other breaking changes which only affect few users. - Renamed `ResolveWorkerOptions` type to `ResolvedWorkerOptions` - [[#5657] fix: return 404 for resources requests outside the base path](https://github.com/vitejs/vite/pull/5657) - In the past, Vite responded to requests outside the base path without `Accept: text/html`, as if they were requested with the base path. Vite no longer does that and responds with 404 instead. +- [[#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. ## Migration from v3 diff --git a/packages/vite/src/node/plugins/resolve.ts b/packages/vite/src/node/plugins/resolve.ts index 7d9a1cc5093b51..556a85101b3db7 100644 --- a/packages/vite/src/node/plugins/resolve.ts +++ b/packages/vite/src/node/plugins/resolve.ts @@ -987,17 +987,8 @@ export function resolvePackageEntry( ) } - const resolvedFromExports = !!entryPoint - - // if exports resolved to .mjs, still resolve other fields. - // This is because .mjs files can technically import .cjs files which would - // make them invalid for pure ESM environments - so if other module/browser - // fields are present, prioritize those instead. - if ( - targetWeb && - options.browserField && - (!entryPoint || entryPoint.endsWith('.mjs')) - ) { + // handle edge case with browser and module field semantics + if (!entryPoint && targetWeb && options.browserField) { // check browser field // https://github.com/defunctzombie/package-browser-field-spec const browserEntry = @@ -1039,8 +1030,7 @@ export function resolvePackageEntry( } // fallback to mainFields if still not resolved - // TODO: review if `.mjs` check is still needed - if (!resolvedFromExports && (!entryPoint || entryPoint.endsWith('.mjs'))) { + if (!entryPoint) { for (const field of options.mainFields) { if (field === 'browser') continue // already checked above if (typeof data[field] === 'string') { From 5631b9439ad171372dcdbdaaa9f37309c736a606 Mon Sep 17 00:00:00 2001 From: bluwy Date: Tue, 24 Oct 2023 00:10:22 +0800 Subject: [PATCH 5/5] release: v5.0.0-beta.12 --- packages/vite/CHANGELOG.md | 11 +++++++++++ packages/vite/package.json | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/vite/CHANGELOG.md b/packages/vite/CHANGELOG.md index bbcb070082a62b..5b95f65e6c8cef 100644 --- a/packages/vite/CHANGELOG.md +++ b/packages/vite/CHANGELOG.md @@ -1,3 +1,14 @@ +## 5.0.0-beta.12 (2023-10-23) + +* fix(resolve)!: remove special .mjs handling (#14723) ([2141d31](https://github.com/vitejs/vite/commit/2141d31)), closes [#14723](https://github.com/vitejs/vite/issues/14723) +* fix(assets): fix svg inline in css url (#14714) ([eef4aaa](https://github.com/vitejs/vite/commit/eef4aaa)), closes [#14714](https://github.com/vitejs/vite/issues/14714) +* fix(resolve): make directory package.json check best effort (#14626) ([d520388](https://github.com/vitejs/vite/commit/d520388)), closes [#14626](https://github.com/vitejs/vite/issues/14626) +* docs: port 4.4.10 to 4.5 changelog to main (#14732) ([2728a31](https://github.com/vitejs/vite/commit/2728a31)), closes [#14732](https://github.com/vitejs/vite/issues/14732) +* refactor(ssr): remove unused metadata code (#14711) ([c5f2d60](https://github.com/vitejs/vite/commit/c5f2d60)), closes [#14711](https://github.com/vitejs/vite/issues/14711) +* chore: link migration guide to changelog (#14699) ([4cedcdc](https://github.com/vitejs/vite/commit/4cedcdc)), closes [#14699](https://github.com/vitejs/vite/issues/14699) + + + ## 5.0.0-beta.11 (2023-10-19) Learn more at the [Vite 5 Migration guide](https://main.vitejs.dev/guide/migration) and help us test the beta! diff --git a/packages/vite/package.json b/packages/vite/package.json index 8827a9fa216f0b..148eee33d23a3a 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -1,6 +1,6 @@ { "name": "vite", - "version": "5.0.0-beta.11", + "version": "5.0.0-beta.12", "type": "module", "license": "MIT", "author": "Evan You",