Skip to content

Commit e75d31f

Browse files
authored
docs: suggest import.meta.hot.accept in server entry (vitejs#20401)
1 parent d2c81f7 commit e75d31f

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

docs/guide/api-environment-frameworks.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,17 @@ app.use('*', async (req, res, next) => {
103103
})
104104
```
105105
106+
When using environments that support HMR (such as `RunnableDevEnvironment`), you should add `import.meta.hot.accept()` in your server entry file for optimal behavior. Without this, server file changes will invalidate the entire server module graph:
107+
108+
```js
109+
// src/entry-server.js
110+
export function render(...) { ... }
111+
112+
if (import.meta.hot) {
113+
import.meta.hot.accept()
114+
}
115+
```
116+
106117
### `FetchableDevEnvironment`
107118
108119
:::info

0 commit comments

Comments
 (0)