Skip to content

sync into main #1326

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Jul 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
dbe79b8
Merge pull request #1322 from vitejs/main
thinkasany Jul 18, 2025
10cea7d
fix(deps): update all non-major dependencies (#20442)
renovate[bot] Jul 22, 2025
bb69633
docs(en): merging all conflicts
docschina-bot Jul 22, 2025
cae97df
fix: resolved conflict
thinkasany Jul 23, 2025
3d803e8
Merge pull request #1323 from vitejs/sync-10cea7dc-1
thinkasany Jul 23, 2025
13c2616
docs: provide correct URL for `pnpm.overrides` (#20469)
iiio2 Jul 25, 2025
a8bd58d
feat: add `server.warmupRequest` to future deprecation (#20431)
sapphi-red Jul 25, 2025
f191834
feat: add `ssrFixStacktrace` / `ssrRewriteStacktrace` to `removeSsrLo…
sapphi-red Jul 25, 2025
c46a93b
feat: add `removeServerPluginContainer` future deprecation (#20437)
sapphi-red Jul 25, 2025
38ae638
refactor: use `http-proxy-3` (#20402)
sapphi-red Jul 25, 2025
d107b40
feat: implement `removeServerHot` future deprecation (#20434)
sapphi-red Jul 25, 2025
3330b78
feat: add `removeServerReloadModule` future deprecation (#20436)
sapphi-red Jul 25, 2025
eae0e29
docs: add NonInheritBadge to options that are not inherited to other …
sapphi-red Jul 25, 2025
5d99c09
docs: minor fixes (#20475)
sapphi-red Jul 25, 2025
4e86b4d
docs: add `markdown-it-image-size` to reduce layout shift (#20474)
sapphi-red Jul 25, 2025
80e02d7
docs(en): merging all conflicts
docschina-bot Jul 25, 2025
434506d
fix dep
thinkasany Jul 26, 2025
b8ef84b
docs: update content
lxKylin Jul 26, 2025
260a873
Merge pull request #1325 from lxKylin/sync-4da
thinkasany Jul 26, 2025
fb9d0a9
Merge pull request #1324 from vitejs/sync-4e86b4da-1
thinkasany Jul 26, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import {
groupIconMdPlugin,
groupIconVitePlugin,
} from 'vitepress-plugin-group-icons'
import llmstxt from 'vitepress-plugin-llms'
import type { PluginOption } from 'vite'
import { markdownItImageSize } from 'markdown-it-image-size'
import { buildEnd } from './buildEnd.config'

const ogDescription = 'Next Generation Frontend Tooling'
Expand Down Expand Up @@ -523,6 +526,9 @@ export default defineConfig({
codeTransformers: [transformerTwoslash()],
config(md) {
md.use(groupIconMdPlugin)
md.use(markdownItImageSize, {
publicDir: path.resolve(import.meta.dirname, '../public'),
})
},
},
vite: {
Expand Down
8 changes: 8 additions & 0 deletions .vitepress/theme/components/NonInheritBadge.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<template>
<a
href="/guide/api-environment#environments-configuration"
class="ignore-header"
>
<Badge type="info" text="non-inherit" />
</a>
</template>
2 changes: 1 addition & 1 deletion .vitepress/theme/components/SponsorBanner.vue
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ function dismiss() {
Register
</a>
</p>
<button @click="dismiss">
<button aria-label="close" @click="dismiss">
<svg
class="close"
xmlns="http://www.w3.org/2000/svg"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const props = withDefaults(defineProps<Props>(), {
v-if="props.framework.logo"
:src="props.framework.logo"
:alt="props.framework.name"
loading="lazy"
/>
</component>
</template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ defineProps<{
:src="testimonial.avatar"
:alt="testimonial.name"
class="card__avatar"
loading="lazy"
/>
<div class="card__meta">
<span class="card__name">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ SolidJS in mind, they should scale from our simplest template to opinionated sta
name: 'David Cramer',
handle: '@zeeg',
avatar:
'https://pbs.twimg.com/profile_images/1706891973553168384/zdAPOznc_400x400.jpg',
'https://pbs.twimg.com/profile_images/1911613315765133312/HVkULegC_400x400.jpg',
comment: ['Vite has been a game changer for the industry.'],
},
{
Expand All @@ -69,7 +69,7 @@ SolidJS in mind, they should scale from our simplest template to opinionated sta
name: 'Christoph Nakazawa',
handle: '@cpojer',
avatar:
'https://pbs.twimg.com/profile_images/1854151427595407360/4GyUCgEH_400x400.jpg',
'https://pbs.twimg.com/profile_images/1910252462126313472/gXgT-jxL_400x400.jpg',
comment: ['Vite is gonna eat the (JavaScript) world.'],
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const { data } = useSponsor()
alt="Vite is made possible by our contributors, partner companies, and sponsors"
width="58"
height="55"
loading="lazy"
/>
<h2>免费 &amp; 开源</h2>
<h4>
Expand All @@ -54,7 +55,7 @@ const { data } = useSponsor()
<h4>由以下团队呈现</h4>
<div class="voidzero">
<a :href="voidZero.url" target="_blank">
<img :src="voidZero.img" />
<img :src="voidZero.img" alt="VoidZero logo" loading="lazy" />
</a>
</div>

Expand Down
2 changes: 2 additions & 0 deletions .vitepress/theme/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import ReleaseTag from './components/ReleaseTag.vue'
import './custom.css'
import YouTubeVideo from './components/YouTubeVideo.vue'
import SponsorBanner from './components/SponsorBanner.vue'
import NonInheritBadge from './components/NonInheritBadge.vue'
import 'virtual:group-icons.css'

export default {
Expand All @@ -27,6 +28,7 @@ export default {
app.component('SvgImage', SvgImage)
app.component('ReleaseTag', ReleaseTag)
app.component('YouTubeVideo', YouTubeVideo)
app.component('NonInheritBadge', NonInheritBadge)
app.use(TwoslashFloatingVue)
},
} satisfies Theme
Expand Down
7 changes: 7 additions & 0 deletions changes/per-environment-apis.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
```ts
future: {
removeServerModuleGraph: 'warn',
removeServerReloadModule: 'warn',
removeServerPluginContainer: 'warn',
removeServerHot: 'warn',
removeServerTransformRequest: 'warn',
removeServerWarmupRequest: 'warn',
}
```

Expand All @@ -29,5 +33,8 @@ future: {
## 迁移指南 {#migration-guide}

- `server.moduleGraph` -> [`environment.moduleGraph`](/guide/api-environment-instances#separate-module-graphs)
- `server.reloadModule(module)` -> `environment.reloadModule(module)`
- `server.pluginContainer` -> `environment.pluginContainer`
- `server.transformRequest(url, ssr)` -> `environment.transformRequest(url)`
- `server.warmupRequest(url, ssr)` -> `environment.warmupRequest(url)`
- `server.hot` -> `server.client.environment.hot`
2 changes: 2 additions & 0 deletions changes/ssr-using-modulerunner.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@
## 迁移指南 {#migration-guide}

请查看 [用于框架的环境 API 指南](../guide/api-environment-frameworks.md)。

当使用 Module Runner API 时,不再需要调用 `server.ssrFixStacktrace` 和 `server.ssrRewriteStacktrace`。除非 `sourcemapInterceptor` 被设置为 `false`,否则堆栈追踪信息将会自动更新。
18 changes: 9 additions & 9 deletions config/dep-optimization-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

除非另有说明,本节中的选项仅适用于依赖优化器,该优化器仅在开发环境中使用。

## optimizeDeps.entries
## optimizeDeps.entries <NonInheritBadge />

- **类型:** `string | string[]`

默认情况下,Vite 会抓取你的 `index.html` 来检测需要预构建的依赖项(忽略了`node_modules`、`build.outDir`、`__tests__` 和 `coverage`)。如果指定了 `build.rollupOptions.input`,Vite 将转而去抓取这些入口点。

如果这两者都不合你意,则可以使用此选项指定自定义条目——该值需要遵循 [tinyglobby 模式](https://github.com/SuperchupuDev/tinyglobby) ,或者是相对于 Vite 项目根目录的匹配模式数组。当显式声明了 `optimizeDeps.entries` 时默认只有 `node_modules` 和 `build.outDir` 文件夹会被忽略。如果还需忽略其他文件夹,你可以在模式列表中使用以 `!` 为前缀的、用来匹配忽略项的模式。对于明确包含字符串 `node_modules` 的模式,不会忽略 `node_modules`。

## optimizeDeps.exclude {#optimizedeps-exclude}
## optimizeDeps.exclude <NonInheritBadge /> {#optimizedeps-exclude}

- **类型:** `string[]`

Expand All @@ -33,7 +33,7 @@ export default defineConfig({

:::

## optimizeDeps.include {#optimizedeps-include}
## optimizeDeps.include <NonInheritBadge /> {#optimizedeps-include}

- **类型:** `string[]`

Expand All @@ -51,7 +51,7 @@ export default defineConfig({
})
```

## optimizeDeps.esbuildOptions {#optimizedeps-esbuild-options}
## optimizeDeps.esbuildOptions <NonInheritBadge /> {#optimizedeps-esbuild-options}

- **类型:** [`Omit`](https://www.typescriptlang.org/docs/handbook/utility-types.html#omittype-keys)`<`[`EsbuildBuildOptions`](https://esbuild.github.io/api/#general-options)`,
| 'bundle'
Expand All @@ -72,28 +72,28 @@ export default defineConfig({
- 忽略了 `external` 选项,请使用 Vite 的 `optimizeDeps.exclude` 选项
- `plugins` 与 Vite 的 dep 插件合并

## optimizeDeps.force {#optimizedeps-force}
## optimizeDeps.force <NonInheritBadge /> {#optimizedeps-force}

- **类型:** `boolean`

设置为 `true` 可以强制依赖预构建,而忽略之前已经缓存过的、已经优化过的依赖。

## optimizeDeps.noDiscovery {#optimizedeps-no-discovery}
## optimizeDeps.noDiscovery <NonInheritBadge /> {#optimizedeps-no-discovery}

- **类型:** `boolean`
- **默认:** `false`

设置为 true 时,自动依赖项发现将被禁用,并且仅优化 `optimizeDeps.include` 中列出的依赖项。在开发过程中,仅 CJS 依赖项必须存在于 `optimizeDeps.include` 中。

## optimizeDeps.holdUntilCrawlEnd
## optimizeDeps.holdUntilCrawlEnd <NonInheritBadge />

- **实验性:** [提供反馈](https://github.com/vitejs/vite/discussions/15834)
- **类型:** `boolean`
- **默认:** `true`

当该功能被启用时,系统会在冷启动时保持第一个优化的依赖结果,直到所有的静态导入都被检索完毕。这样可以避免因为发现新的依赖项而触发新的公共 chunk 生成,从而需要刷新整个页面。如果通过扫描和在 `include` 中明确定义的方式能找到所有的依赖项,那么最好关闭这个功能,这样浏览器可以并行处理更多的请求。

## optimizeDeps.disabled {#optimizedeps-disabled}
## optimizeDeps.disabled <NonInheritBadge /> {#optimizedeps-disabled}

- **已废弃**
- **实验性:** [提供反馈](https://github.com/vitejs/vite/discussions/13839)
Expand All @@ -108,7 +108,7 @@ export default defineConfig({
在构建过程中优化依赖项是一个 **实验性** 的功能。尝试这种策略的项目也会使用 `build.commonjsOptions: { include: [] }` 来移除 `@rollup/plugin-commonjs`。如果你这样做,将会有一个警告提示你在打包时需要重新启用它,以支持仅使用 CJS 的包。
:::

## optimizeDeps.needsInterop
## optimizeDeps.needsInterop <NonInheritBadge />

- **实验性**
- **类型:** `string[]`
Expand Down
2 changes: 1 addition & 1 deletion config/preview-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export default defineConfig({

为开发服务器配置自定义代理规则。其值的结构为 `{ key: options }` 的对象。如果 key 以 `^` 开头,它将被识别为 `RegExp`,其中 `configure` 选项可用于访问代理实例。

基于 [`http-proxy`](https://github.com/http-party/node-http-proxy) 实现,完整的参数列表参见 [此链接](https://github.com/http-party/node-http-proxy#options)。
基于 [`http-proxy-3`](https://github.com/sagemathinc/http-proxy-3) 实现,完整的参数列表参见 [此链接](https://github.com/sagemathinc/http-proxy-3#options)。

## preview.cors {#preview-cors}

Expand Down
2 changes: 1 addition & 1 deletion config/server-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export default defineConfig({

请注意,如果使用了非相对的 [基础路径 `base`](/config/shared-options.md#base),则必须在每个 key 值前加上该 `base`。

继承自 [`http-proxy`](https://github.com/http-party/node-http-proxy#options)。完整选项详见 [此处](https://github.com/vitejs/vite/blob/main/packages/vite/src/node/server/middlewares/proxy.ts#L13)。
继承自 [`http-proxy-3`](https://github.com/sagemathinc/http-proxy-3#options)。完整选项详见 [此处](https://github.com/vitejs/vite/blob/main/packages/vite/src/node/server/middlewares/proxy.ts#L13)。

在某些情况下,你可能也想要配置底层的开发服务器。(例如添加自定义的中间件到内部的 [connect](https://github.com/senchalabs/connect) 应用中)为了实现这一点,你需要编写你自己的 [插件](/guide/using-plugins.html) 并使用 [configureServer](/guide/api-plugin.html#configureserver) 函数。

Expand Down
4 changes: 2 additions & 2 deletions config/shared-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ declare const __APP_VERSION__: string
对于服务端渲染构建,配置项 `build.rollupOptions.output` 为 ESM 构建输出时去重过程将不工作。一个替代方案是先使用 CJS 构建输出,直到 ESM 在插件中有了更好的模块加载支持。
:::

## resolve.conditions {#resolve-conditions}
## resolve.conditions <NonInheritBadge /> {#resolve-conditions}

- **类型:** `string[]`
- **默认:** `['module', 'browser', 'development|production']` (`defaultClientConditions`)
Expand All @@ -140,7 +140,7 @@ declare const __APP_VERSION__: string

请注意,如果符合要求,`import`,`require`,`default` 始终会被应用。

## resolve.mainFields {#resolve-mainfields}
## resolve.mainFields <NonInheritBadge /> {#resolve-mainfields}

- **类型:** `string[]`
- **默认:** `['browser', 'module', 'jsnext:main', 'jsnext']` (`defaultClientMainFields`)
Expand Down
2 changes: 1 addition & 1 deletion guide/api-environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export default {
}
```

如果没有明确说明,环境将继承已配置的顶级配置选项(例如,新的 `server` 和 `edge` 环境将继承 `build.sourcemap: false` 选项)。少数顶级选项(如 `optimizeDeps`)仅适用于 `client` 环境,因为它们在默认应用于服务器环境时效果不佳。也可以通过 `environments.client` 明确配置 `client` 环境,但我们建议使用顶级选项进行配置,以便在添加新环境时客户端配置保持不变。
如果没有明确说明,环境将继承已配置的顶级配置选项(例如,新的 `server` 和 `edge` 环境将继承 `build.sourcemap: false` 选项)。少数顶级选项(如 `optimizeDeps`)仅适用于 `client` 环境,因为它们在默认应用于服务器环境时效果不佳。这些选项在[配置参考](/config/)中带有 <NonInheritBadge /> 标记。也可以通过 `environments.client` 明确配置 `client` 环境,但我们建议使用顶级选项进行配置,以便在添加新环境时客户端配置保持不变。

`EnvironmentOptions` 接口公开所有每个环境选项。有些环境选项适用于 `build` 和 `dev`,如 `resolve`。还有 `DevEnvironmentOptions` 和 `BuildEnvironmentOptions` 用于开发和构建特定选项(如 `dev.warmup` 或 `build.outDir`)。一些选项(例如`optimizeDeps`)仅适用于 dev,但为了向后兼容,它保留为顶层而不是嵌套在`dev`中。

Expand Down
2 changes: 1 addition & 1 deletion guide/api-plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Vite 努力秉承开箱即用的原则,因此在创作一款新插件前,请

::: tip
在学习、调试或创作插件时,我们建议在你的项目中引入 [vite-plugin-inspect](https://github.com/antfu/vite-plugin-inspect)。 它可以帮助你检查 Vite 插件的中间状态。安装后,你可以访问 `localhost:5173/__inspect/` 来检查你项目的模块和栈信息。请查阅 [vite-plugin-inspect 文档](https://github.com/antfu/vite-plugin-inspect) 中的安装说明。
![vite-plugin-inspect](/images/vite-plugin-inspect.png)
![vite-plugin-inspect](../images/vite-plugin-inspect.png)
:::

## 约定 {#conventions}
Expand Down
2 changes: 1 addition & 1 deletion guide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ pnpm link --global # 在这一步中可使用你喜欢的包管理器
然后,回到你的 Vite 项目并运行 `pnpm link --global vite`(或者使用你的其他包管理工具来全局链接 `vite`)。重新启动开发服务器来体验新功能吧!

::: tip 处理依赖中的 Vite 版本
若需替换依赖链中传递使用的 Vite 版本(Transitive Dependencies),应使用 [npm overrides](https://docs.npmjs.com/cli/v11/configuring-npm/package-json#overrides) 或 [pnpm overrides](https://pnpm.io/package_json#pnpmoverrides)。
若需替换依赖链中传递使用的 Vite 版本(Transitive Dependencies),应使用 [npm overrides](https://docs.npmjs.com/cli/v11/configuring-npm/package-json#overrides) 或 [pnpm overrides](https://pnpm.io/9.x/package_json#pnpmoverrides)。
:::

## 社区 {#community}
Expand Down
2 changes: 1 addition & 1 deletion guide/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ import './Foo.js' // 应该为 './foo.js'

### 链接本地包时过期预构建依赖项 {#outdated-pre-bundled-deps-when-linking-to-a-local-package}

在 Vite 中通过一个哈希值来决定优化后的依赖项是否有效,这个值取决于包锁定的内容、应用于依赖项的补丁以及 Vite 配置文件中影响 node_modules 打包的选项。这意味着,当使用像 [npm overrides](https://docs.npmjs.com/cli/v9/configuring-npm/package-json#overrides) 这样的功能覆盖依赖项时,Vite 将检测到,并在下一次服务器启动时重新打包您的依赖项。当您使用像 [npm link](https://docs.npmjs.com/cli/v9/commands/npm-link) 这样的功能时,Vite 不会使依赖项无效。如果您链接或取消链接一个依赖项,那么您需要使用 `vite --force` 在下一次服务器启动时强制重新预构建。我们建议使用 overrides,它们现在被每个包管理器所支持(还可以参见 [pnpm overrides](https://pnpm.io/package_json#pnpmoverrides) 和 [yarn resolutions](https://yarnpkg.com/configuration/manifest/#resolutions))。
在 Vite 中通过一个哈希值来决定优化后的依赖项是否有效,这个值取决于包锁定的内容、应用于依赖项的补丁以及 Vite 配置文件中影响 node_modules 打包的选项。这意味着,当使用像 [npm overrides](https://docs.npmjs.com/cli/v9/configuring-npm/package-json#overrides) 这样的功能覆盖依赖项时,Vite 将检测到,并在下一次服务器启动时重新打包您的依赖项。当您使用像 [npm link](https://docs.npmjs.com/cli/v9/commands/npm-link) 这样的功能时,Vite 不会使依赖项无效。如果您链接或取消链接一个依赖项,那么您需要使用 `vite --force` 在下一次服务器启动时强制重新预构建。我们建议使用 overrides,它们现在被每个包管理器所支持(还可以参见 [pnpm overrides](https://pnpm.io/9.x/package_json#pnpmoverrides) 和 [yarn resolutions](https://yarnpkg.com/configuration/manifest/#resolutions))。

## 性能瓶颈 {#performance-bottlenecks}

Expand Down
16 changes: 9 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,21 @@
"license": "CC BY-NC-SA 4.0",
"devDependencies": {
"@shikijs/vitepress-twoslash": "^3.7.0",
"@type-challenges/utils": "^0.1.1",
"@types/express": "^5.0.3",
"feed": "^5.1.0",
"vitepress": "^2.0.0-alpha.7",
"vitepress-plugin-group-icons": "^1.6.1",
"vue": "3.6.0-alpha.1",
"@types/node": "^20.9.2",
"@type-challenges/utils": "^0.1.1",
"chalk": "^4.1.2",
"feed": "^5.1.0",
"gray-matter": "^4.0.3",
"gsap": "^3.13.0",
"lodash": "^4.17.21",
"markdown-it-image-size": "^14.7.0",
"vite": "^7.0.4",
"yorkie": "^2.0.0",
"gsap": "^3.13.0"
"vitepress": "^2.0.0-alpha.7",
"vitepress-plugin-group-icons": "^1.6.1",
"vitepress-plugin-llms": "^1.7.1",
"vue": "3.6.0-alpha.1",
"yorkie": "^2.0.0"
},
"packageManager": "[email protected]",
"engines": {
Expand Down
Loading