Skip to content

Commit

Permalink
feat: reload when non-JS files change (#540)
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico committed Jun 24, 2020
1 parent c989a20 commit f29b9fe
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/commands/dev.ts
Expand Up @@ -908,11 +908,7 @@ export async function command(commandOptions: CommandOptions) {
if (!updateUrl) {
return;
}
// HTML files don't support HMR, so just reload the current page.
if (updateUrl.endsWith('.html')) {
hmrEngine.broadcastMessage({type: 'reload'});
return;
}

// Append ".proxy.js" to Non-JS files to match their registered URL in the client app.
if (!updateUrl.endsWith('.js') && !updateUrl.endsWith('.module.css')) {
updateUrl += '.proxy.js';
Expand All @@ -930,6 +926,14 @@ export async function command(commandOptions: CommandOptions) {
// If the changed file exists on the page, trigger a new HMR update.
if (hmrEngine.getEntry(updateUrl)) {
updateOrBubble(updateUrl, new Set());
return;
}

// Otherwise, reload the page if the file exists in our hot cache (which means that the
// file likely exists on the current page, but is not supported by HMR (HTML, image, etc)).
if (inMemoryBuildCache.has(fileLoc)) {
hmrEngine.broadcastMessage({type: 'reload'});
return;
}
}

Expand Down

1 comment on commit f29b9fe

@vercel
Copy link

@vercel vercel bot commented on f29b9fe Jun 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.