Skip to content

Commit d4bac2d

Browse files
authored
Merge pull request #1099 from vitejs/dev
merge dev into main
2 parents feb8676 + 1a8a089 commit d4bac2d

File tree

3 files changed

+53
-10
lines changed

3 files changed

+53
-10
lines changed

.vitepress/theme/components/landing/4. community-section/CommunitySection.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ SolidJS in mind, they should scale from our simplest template to opinionated sta
7070
name: 'Christoph Nakazawa',
7171
handle: '@cpojer',
7272
avatar:
73-
'https://pbs.twimg.com/profile_images/1189537722286952449/OrscO0bD_400x400.jpg',
73+
'https://pbs.twimg.com/profile_images/1854151427595407360/4GyUCgEH_400x400.jpg',
7474
comment: ['Vite is gonna eat the (JavaScript) world.'],
7575
},
7676
{

guide/api-environment-runtimes.md

+4-8
Original file line numberDiff line numberDiff line change
@@ -190,15 +190,10 @@ export interface ModuleRunnerOptions {
190190
| InterceptorOptions
191191
/**
192192
* 禁用 HMR 或配置 HMR 选项
193+
*
194+
* @default true
193195
*/
194-
hmr?:
195-
| false
196-
| {
197-
/**
198-
* 配置 HMR 日志.
199-
*/
200-
logger?: false | HMRLogger
201-
}
196+
hmr?: boolean | ModuleRunnerHmr
202197
/**
203198
* 自定义模块缓存。如果未提供,它将创建一个单独的模块缓存给
204199
* 每个模块运行器实例
@@ -356,6 +351,7 @@ export const runner = new ModuleRunner(
356351
return response.json()
357352
},
358353
},
354+
hmr: false, // disable HMR as HMR requires transport.connect
359355
},
360356
new ESModulesEvaluator(),
361357
)

guide/migration.md

+48-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,54 @@ Vite 6 扩展了对更多 HTML 元素的支持。完整列表请参见 [HTML 功
100100
- [[#18493] refactor!: remove fs.cachedChecks option](https://github.com/vitejs/vite/pull/18493)
101101
- 由于在缓存文件夹中写入文件并立即导入时会出现边缘情况,因此删除了这一选择优化。
102102
- [[#18697] fix(deps)!: update dependency dotenv-expand to v12](https://github.com/vitejs/vite/pull/18697)
103-
- 插值中使用的变量应在插值之前声明。更多详情,请参阅 [`dotenv-expand` changelog](https://github.com/motdotla/dotenv-expand/blob/v12.0.1/CHANGELOG.md#1200-2024-11-16).
103+
- 插值中使用的变量应在插值之前声明。更多详情,请参阅 [`dotenv-expand` changelog](https://github.com/motdotla/dotenv-expand/blob/v12.0.1/CHANGELOG.md#1200-2024-11-16)
104+
- [[#16471] feat: v6 - Environment API](https://github.com/vitejs/vite/pull/16471)
105+
106+
- 对仅 SSR 模块的更新不再触发客户端的页面重载。要恢复以前的行为,可使用自定义 Vite 插件:
107+
<details>
108+
<summary>点击展开示例</summary>
109+
110+
```ts twoslash
111+
import type { Plugin, EnvironmentModuleNode } from 'vite'
112+
113+
function hmrReload(): Plugin {
114+
return {
115+
name: 'hmr-reload',
116+
enforce: 'post',
117+
hotUpdate: {
118+
order: 'post',
119+
handler({ modules, server, timestamp }) {
120+
if (this.environment.name !== 'ssr') return
121+
122+
let hasSsrOnlyModules = false
123+
124+
const invalidatedModules = new Set<EnvironmentModuleNode>()
125+
for (const mod of modules) {
126+
if (mod.id == null) continue
127+
const clientModule =
128+
server.environments.client.moduleGraph.getModuleById(mod.id)
129+
if (clientModule != null) continue
130+
131+
this.environment.moduleGraph.invalidateModule(
132+
mod,
133+
invalidatedModules,
134+
timestamp,
135+
true,
136+
)
137+
hasSsrOnlyModules = true
138+
}
139+
140+
if (hasSsrOnlyModules) {
141+
server.ws.send({ type: 'full-reload' })
142+
return []
143+
}
144+
},
145+
},
146+
}
147+
}
148+
```
149+
150+
</details>
104151

105152
## 从 v4 迁移 {#migration-from-v4}
106153

0 commit comments

Comments
 (0)