@@ -100,7 +100,54 @@ Vite 6 扩展了对更多 HTML 元素的支持。完整列表请参见 [HTML 功
100
100
- [[ #18493 ] refactor!: remove fs.cachedChecks option] ( https://github.com/vitejs/vite/pull/18493 )
101
101
- 由于在缓存文件夹中写入文件并立即导入时会出现边缘情况,因此删除了这一选择优化。
102
102
- [[ #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 >
104
151
105
152
## 从 v4 迁移 {#migration - from - v4 }
106
153
0 commit comments