-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
feat(hmr): reload when HTML file is created/deleted #16288
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
4f817d1
1f0b656
de606d4
635188e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -82,7 +82,6 @@ import { | |
| createHMRBroadcaster, | ||
| createServerHMRChannel, | ||
| getShortName, | ||
| handleFileAddUnlink, | ||
| handleHMRUpdate, | ||
| updateModules, | ||
| } from './hmr' | ||
|
|
@@ -728,10 +727,13 @@ export async function _createServer( | |
|
|
||
| const publicFiles = await initPublicFilesPromise | ||
|
|
||
| const onHMRUpdate = async (file: string, configOnly: boolean) => { | ||
| const onHMRUpdate = async ( | ||
| type: 'create' | 'delete' | 'update', | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have an opportunity to define new names for the new There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I aligned these names with the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, perfect 👍🏼 |
||
| file: string, | ||
| ) => { | ||
| if (serverConfig.hmr !== false) { | ||
| try { | ||
| await handleHMRUpdate(file, server, configOnly) | ||
| await handleHMRUpdate(type, file, server) | ||
| } catch (err) { | ||
| hot.send({ | ||
| type: 'error', | ||
|
|
@@ -762,16 +764,16 @@ export async function _createServer( | |
| } | ||
| } | ||
| } | ||
| await handleFileAddUnlink(file, server, isUnlink) | ||
| await onHMRUpdate(file, true) | ||
| if (isUnlink) moduleGraph.onFileDelete(file) | ||
| await onHMRUpdate(isUnlink ? 'delete' : 'create', file) | ||
| } | ||
|
|
||
| watcher.on('change', async (file) => { | ||
| file = normalizePath(file) | ||
| await container.watchChange(file, { event: 'update' }) | ||
| // invalidate module graph cache on file change | ||
| moduleGraph.onFileChange(file) | ||
| await onHMRUpdate(file, false) | ||
| await onHMRUpdate('update', file) | ||
| }) | ||
|
|
||
| getFsUtils(config).initWatcher?.(watcher) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sapphi-red when file create/delete, user custom plugin hook
handleHotUpdatewon't be invoke?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
https://vite.dev/changes/hotupdate-hook.html#:~:text=handle%20additional%20watch%20events%20with%20create%20and%20delete.