diff --git a/snowpack/assets/hmr-client.js b/snowpack/assets/hmr-client.js index ab137dac37..e2e1918a0c 100644 --- a/snowpack/assets/hmr-client.js +++ b/snowpack/assets/hmr-client.js @@ -110,7 +110,7 @@ export function createHotContext(fullUrl) { } /** Called when a new module is loaded, to pass the updated module to the "active" module */ -async function runModuleAccept(id) { +async function runModuleAccept({url: id, bubbled}) { const state = REGISTERED_MODULES[id]; if (!state) { return false; @@ -125,7 +125,7 @@ async function runModuleAccept(id) { import(id + `?mtime=${updateID}`), ...deps.map((d) => import(d + `?mtime=${updateID}`)), ]); - acceptCallback({module, deps: depModules}); + acceptCallback({module, bubbled, deps: depModules}); } return true; } @@ -165,7 +165,7 @@ socket.addEventListener('message', ({data: _data}) => { } if (data.type === 'update') { log('message: update', data); - runModuleAccept(data.url) + runModuleAccept(data) .then((ok) => { if (ok) { clearErrorOverlay(); diff --git a/snowpack/src/commands/dev.ts b/snowpack/src/commands/dev.ts index 1142141f7d..50ad8c886e 100644 --- a/snowpack/src/commands/dev.ts +++ b/snowpack/src/commands/dev.ts @@ -970,11 +970,12 @@ export async function startServer(commandOptions: CommandOptions) { if (visited.has(url)) { return; } - visited.add(url); const node = hmrEngine.getEntry(url); + const isBubbled = visited.size > 0; if (node && node.isHmrEnabled) { - hmrEngine.broadcastMessage({type: 'update', url}); + hmrEngine.broadcastMessage({type: 'update', url, bubbled: isBubbled}); } + visited.add(url); if (node && node.isHmrAccepted) { // Found a boundary, no bubbling needed } else if (node && node.dependents.size > 0) { diff --git a/snowpack/src/hmr-server-engine.ts b/snowpack/src/hmr-server-engine.ts index e6beec9bf0..e236649782 100644 --- a/snowpack/src/hmr-server-engine.ts +++ b/snowpack/src/hmr-server-engine.ts @@ -14,7 +14,7 @@ interface Dependency { type HMRMessage = | {type: 'reload'} - | {type: 'update'; url: string} + | {type: 'update'; url: string; bubbled: boolean;} | { type: 'error'; title: string;