Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,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/1189537722286952449/OrscO0bD_400x400.jpg',
'https://pbs.twimg.com/profile_images/1854151427595407360/4GyUCgEH_400x400.jpg',
comment: ['Vite is gonna eat the (JavaScript) world.'],
},
{
Expand Down
12 changes: 4 additions & 8 deletions guide/api-environment-runtimes.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,10 @@ export interface ModuleRunnerOptions {
| InterceptorOptions
/**
* 禁用 HMR 或配置 HMR 选项
*
* @default true
*/
hmr?:
| false
| {
/**
* 配置 HMR 日志.
*/
logger?: false | HMRLogger
}
hmr?: boolean | ModuleRunnerHmr
/**
* 自定义模块缓存。如果未提供,它将创建一个单独的模块缓存给
* 每个模块运行器实例
Expand Down Expand Up @@ -356,6 +351,7 @@ export const runner = new ModuleRunner(
return response.json()
},
},
hmr: false, // disable HMR as HMR requires transport.connect
},
new ESModulesEvaluator(),
)
Expand Down
49 changes: 48 additions & 1 deletion guide/migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,54 @@ Vite 6 扩展了对更多 HTML 元素的支持。完整列表请参见 [HTML 功
- [[#18493] refactor!: remove fs.cachedChecks option](https://github.com/vitejs/vite/pull/18493)
- 由于在缓存文件夹中写入文件并立即导入时会出现边缘情况,因此删除了这一选择优化。
- [[#18697] fix(deps)!: update dependency dotenv-expand to v12](https://github.com/vitejs/vite/pull/18697)
- 插值中使用的变量应在插值之前声明。更多详情,请参阅 [`dotenv-expand` changelog](https://github.com/motdotla/dotenv-expand/blob/v12.0.1/CHANGELOG.md#1200-2024-11-16).
- 插值中使用的变量应在插值之前声明。更多详情,请参阅 [`dotenv-expand` changelog](https://github.com/motdotla/dotenv-expand/blob/v12.0.1/CHANGELOG.md#1200-2024-11-16)。
- [[#16471] feat: v6 - Environment API](https://github.com/vitejs/vite/pull/16471)

- 对仅 SSR 模块的更新不再触发客户端的页面重载。要恢复以前的行为,可使用自定义 Vite 插件:
<details>
<summary>点击展开示例</summary>

```ts twoslash
import type { Plugin, EnvironmentModuleNode } from 'vite'

function hmrReload(): Plugin {
return {
name: 'hmr-reload',
enforce: 'post',
hotUpdate: {
order: 'post',
handler({ modules, server, timestamp }) {
if (this.environment.name !== 'ssr') return

let hasSsrOnlyModules = false

const invalidatedModules = new Set<EnvironmentModuleNode>()
for (const mod of modules) {
if (mod.id == null) continue
const clientModule =
server.environments.client.moduleGraph.getModuleById(mod.id)
if (clientModule != null) continue

this.environment.moduleGraph.invalidateModule(
mod,
invalidatedModules,
timestamp,
true,
)
hasSsrOnlyModules = true
}

if (hasSsrOnlyModules) {
server.ws.send({ type: 'full-reload' })
return []
}
},
},
}
}
```

</details>

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

Expand Down