You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Build as a library. `entry` is required since the library cannot use HTML as entry. `name` is the exposed global variable and is required when `formats` includes `'umd'` or `'iife'`. Default `formats` are `['es', 'umd']`. `fileName` is the name of the package file output, default `fileName` is the name option of package.json, it can also be defined as function taking the `format` and `entryAlias` as arguments.
Copy file name to clipboardExpand all lines: guide/api-hmr.md
+5-15
Original file line number
Diff line number
Diff line change
@@ -125,41 +125,31 @@ if (import.meta.hot) {
125
125
126
126
## `hot.invalidate()` {#hot-invalidate}
127
127
128
-
<<<<<<< HEAD
129
-
现在调用 `import.meta.hot.invalidate()` 只是重新加载页面。
130
-
=======
131
-
A self-accepting module may realize during runtime that it can't handle a HMR update, and so the update needs to be forcefully propagated to importers. By calling `import.meta.hot.invalidate()`, the HMR server will invalidate the importers of the caller, as if the caller wasn't self-accepting.
Note that you should always call `import.meta.hot.accept` even if you plan to call `invalidate` immediately afterwards, or else the HMR client won't listen for future changes to the self-accepting module. To communicate your intent clearly, we recommend calling `invalidate` within the `accept` callback like so:
134
132
135
133
```js
136
134
import.meta.hot.accept((module) => {
137
-
//You may use the new module instance to decide whether to invalidate.
@@ -210,9 +206,8 @@ Or, if exposing multiple entry points:
210
206
}
211
207
```
212
208
213
-
::: tip Note
214
-
If the `package.json` does not contain `"type": "module"`, Vite will generate different file extensions for Node.js compatibility. `.js` will become `.mjs` and `.cjs` will become `.js`.
0 commit comments