Skip to content

Commit

Permalink
Merge branch 'main' into browser-field-away
Browse files Browse the repository at this point in the history
  • Loading branch information
bluwy committed Oct 23, 2023
2 parents 1157c06 + 5631b94 commit 297b425
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 83 deletions.
4 changes: 4 additions & 0 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ export default defineConfig({
text: 'Awesome Vite',
link: 'https:/vitejs/awesome-vite',
},
{
text: 'ViteConf',
link: 'https://viteconf.org',
},
{
text: 'DEV Community',
link: 'https://dev.to/t/vite',
Expand Down
63 changes: 0 additions & 63 deletions docs/.vitepress/theme/components/AsideSponsors.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,68 +18,5 @@ const sponsors = computed(() => {
</script>

<template>
<a class="viteconf" href="https://viteconf.org/23" target="_blank">
<img width="22" height="22" src="/viteconf.svg" />
<span>
<p class="extra-info">Free Online Conference</p>
<p class="heading">ViteConf 23 - Oct 5</p>
<p class="extra-info">Get your ticket now!</p>
</span>
</a>
<VPDocAsideSponsors v-if="data" :data="sponsors" />
</template>

<style>
.viteconf {
margin-top: 1rem;
margin-bottom: 1rem;
border-radius: 14px;
padding-left: 2.5rem;
padding-top: 0.4rem;
padding-bottom: 0.4rem;
position: relative;
font-size: 0.9rem;
font-weight: 700;
line-height: 1.1rem;
display: flex;
align-items: center;
justify-content: center;
gap: 0.75rem;
background-color: var(--vp-c-bg-alt);
border: 2px solid var(--vp-c-bg-alt);
transition: border-color 0.5s;
}
.viteconf:hover {
border: 2px solid var(--vp-c-brand-light);
}
.viteconf img {
position: absolute;
left: 1.5rem;
transition: transform 0.5s;
transform: scale(1.25);
}
.viteconf:hover img {
transform: scale(1.75);
}
.viteconf .heading {
background-image: linear-gradient(
120deg,
#b047ff 16%,
var(--vp-c-brand-lighter),
var(--vp-c-brand-lighter)
);
background-clip: text;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
.viteconf .extra-info {
color: var(--vp-c-text-1);
opacity: 0;
font-size: 0.7rem;
padding-left: 0.1rem;
transition: opacity 0.5s;
}
.viteconf:hover .extra-info {
opacity: 0.9;
}
</style>
2 changes: 2 additions & 0 deletions docs/guide/migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:/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:/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:/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`.

Expand Down
3 changes: 0 additions & 3 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ hero:
- theme: alt
text: View on GitHub
link: https:/vitejs/vite
- theme: brand
text: 🎉 ViteConf 23!
link: https://viteconf.org/23

features:
- icon: 💡
Expand Down
50 changes: 50 additions & 0 deletions packages/vite/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
## 5.0.0-beta.12 (2023-10-23)

* fix(resolve)!: remove special .mjs handling (#14723) ([2141d31](https:/vitejs/vite/commit/2141d31)), closes [#14723](https:/vitejs/vite/issues/14723)
* fix(assets): fix svg inline in css url (#14714) ([eef4aaa](https:/vitejs/vite/commit/eef4aaa)), closes [#14714](https:/vitejs/vite/issues/14714)
* fix(resolve): make directory package.json check best effort (#14626) ([d520388](https:/vitejs/vite/commit/d520388)), closes [#14626](https:/vitejs/vite/issues/14626)
* docs: port 4.4.10 to 4.5 changelog to main (#14732) ([2728a31](https:/vitejs/vite/commit/2728a31)), closes [#14732](https:/vitejs/vite/issues/14732)
* refactor(ssr): remove unused metadata code (#14711) ([c5f2d60](https:/vitejs/vite/commit/c5f2d60)), closes [#14711](https:/vitejs/vite/issues/14711)
* chore: link migration guide to changelog (#14699) ([4cedcdc](https:/vitejs/vite/commit/4cedcdc)), closes [#14699](https:/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!
Expand Down Expand Up @@ -201,6 +212,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:/vitejs/vite/commit/45595ef)), closes [#14560](https:/vitejs/vite/issues/14560) [#14670](https:/vitejs/vite/issues/14670)
* feat: scan .marko files (#14669) ([ed7bdc5](https:/vitejs/vite/commit/ed7bdc5)), closes [#14669](https:/vitejs/vite/issues/14669)
* feat(ssr): backport ssr.resolve.conditions and ssr.resolve.externalConditions (#14498) (#14668) ([520139c](https:/vitejs/vite/commit/520139c)), closes [#14498](https:/vitejs/vite/issues/14498) [#14668](https:/vitejs/vite/issues/14668)



## <small>4.4.11 (2023-10-05)</small>

* revert: "fix: use string manipulation instead of regex to inject esbuild helpers ([54e1275](https:/vitejs/vite/commit/54e1275)), closes [#14094](https:/vitejs/vite/issues/14094)



## <small>4.4.10 (2023-10-03)</small>

* fix: add source map to Web Workers (fix #14216) (#14217) ([df6f32f](https:/vitejs/vite/commit/df6f32f)), closes [#14216](https:/vitejs/vite/issues/14216) [#14217](https:/vitejs/vite/issues/14217)
* fix: handle errors during `hasWorkspacePackageJSON` function (#14394) ([6f6e5de](https:/vitejs/vite/commit/6f6e5de)), closes [#14394](https:/vitejs/vite/issues/14394)
* fix: handle sourcemap correctly when multiple line import exists (#14232) ([218861f](https:/vitejs/vite/commit/218861f)), closes [#14232](https:/vitejs/vite/issues/14232)
* fix: if host is specified check whether it is valid (#14013) ([b1b816a](https:/vitejs/vite/commit/b1b816a)), closes [#14013](https:/vitejs/vite/issues/14013)
* fix: include `vite/types/*` in exports field (#14296) ([40e99a1](https:/vitejs/vite/commit/40e99a1)), closes [#14296](https:/vitejs/vite/issues/14296)
* fix: initWasm options should be optional (#14152) ([119c074](https:/vitejs/vite/commit/119c074)), closes [#14152](https:/vitejs/vite/issues/14152)
* fix: restore builtins list ([f8b9adb](https:/vitejs/vite/commit/f8b9adb))
* fix: use string manipulation instead of regex to inject esbuild helpers (#14094) ([128ad8f](https:/vitejs/vite/commit/128ad8f)), closes [#14094](https:/vitejs/vite/issues/14094)
* fix: ws never connects after restarting server if server.hmr.server is set (#14127) ([441642e](https:/vitejs/vite/commit/441642e)), closes [#14127](https:/vitejs/vite/issues/14127)
* fix(analysis): warnings for dynamic imports that use static template literals (#14458) ([0c6d289](https:/vitejs/vite/commit/0c6d289)), closes [#14458](https:/vitejs/vite/issues/14458)
* fix(cli): convert special base (#14283) ([d4bc0fb](https:/vitejs/vite/commit/d4bc0fb)), closes [#14283](https:/vitejs/vite/issues/14283)
* fix(css): remove pure css chunk sourcemap (#14290) ([cd7e033](https:/vitejs/vite/commit/cd7e033)), closes [#14290](https:/vitejs/vite/issues/14290)
* fix(css): reset render cache on renderStart (#14326) ([d334b3d](https:/vitejs/vite/commit/d334b3d)), closes [#14326](https:/vitejs/vite/issues/14326)
* fix(glob): trigger HMR for glob in a package (#14117) ([0f582bf](https:/vitejs/vite/commit/0f582bf)), closes [#14117](https:/vitejs/vite/issues/14117)
* fix(import-analysis): preserve importedUrls import order (#14465) ([269aa43](https:/vitejs/vite/commit/269aa43)), closes [#14465](https:/vitejs/vite/issues/14465)
* fix(manifest): preserve pure css chunk assets (#14297) ([3d63ae6](https:/vitejs/vite/commit/3d63ae6)), closes [#14297](https:/vitejs/vite/issues/14297)
* fix(optimizer): define crawlDeps after scanProcessing and optimizationResult are complete (fix #1428 ([fcaf749](https:/vitejs/vite/commit/fcaf749)), closes [#14284](https:/vitejs/vite/issues/14284) [#14285](https:/vitejs/vite/issues/14285)
* fix(resolve): support submodules of optional peer deps (#14489) ([104971d](https:/vitejs/vite/commit/104971d)), closes [#14489](https:/vitejs/vite/issues/14489)
* fix(vite): precisely check if files are in dirs (#14241) ([c4758d1](https:/vitejs/vite/commit/c4758d1)), closes [#14241](https:/vitejs/vite/issues/14241)
* feat: improve deno and bun support (#14379) ([8bc1f9d](https:/vitejs/vite/commit/8bc1f9d)), closes [#14379](https:/vitejs/vite/issues/14379)



## <small>4.4.9 (2023-08-07)</small>

* chore: fix eslint warnings (#14031) ([4021a0e](https:/vitejs/vite/commit/4021a0e)), closes [#14031](https:/vitejs/vite/issues/14031)
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
26 changes: 11 additions & 15 deletions packages/vite/src/node/plugins/resolve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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:/defunctzombie/package-browser-field-spec#ignore-a-module
export const browserExternalId = '__vite-browser-external'
Expand Down Expand Up @@ -638,7 +640,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
}
}

Expand Down Expand Up @@ -978,17 +982,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.mainFields.includes('browser') &&
(!entryPoint || entryPoint.endsWith('.mjs'))
) {
// handle edge case with browser and module field semantics
if (!entryPoint && targetWeb && options.mainFields.includes('browser')) {
// check browser field
// https:/defunctzombie/package-browser-field-spec
const browserEntry =
Expand Down Expand Up @@ -1030,8 +1025,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') {
Expand Down Expand Up @@ -1094,11 +1088,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(
Expand Down
22 changes: 21 additions & 1 deletion playground/resolve/__tests__/resolve.spec.ts
Original file line number Diff line number Diff line change
@@ -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]')
Expand Down Expand Up @@ -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')),
Expand Down

0 comments on commit 297b425

Please sign in to comment.