Skip to content

Commit

Permalink
make esm-hmr import error reporter more strict
Browse files Browse the repository at this point in the history
  • Loading branch information
FredKSchott committed Oct 4, 2020
1 parent 941b27a commit 339a47f
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions snowpack/assets/hmr-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,17 @@ socket.addEventListener('message', ({data: _data}) => {
})
.catch((err) => {
console.error('[ESM-HMR] Hot Update Error', err);
createNewErrorOverlay({
title: 'Hot Update Error',
fileLoc: data.url,
errorMessage: err.message,
errorStackTrace: err.stack,
});
// A failed import gives a TypeError, but invalid ESM imports/exports give a SyntaxError.
// Failed build results already get reported via a better WebSocket update.
// We only want to report invalid code like a bad import that doesn't exist.
if (err instanceof SyntaxError) {
createNewErrorOverlay({
title: 'Hot Update Error',
fileLoc: data.url,
errorMessage: err.message,
errorStackTrace: err.stack,
});
}
});
return;
}
Expand Down

1 comment on commit 339a47f

@vercel
Copy link

@vercel vercel bot commented on 339a47f Oct 4, 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.