Skip to content

Commit

Permalink
fix(preview): trigger onLoad event on webpack compilation errors (#9109)
Browse files Browse the repository at this point in the history
  • Loading branch information
luvkapur authored Aug 12, 2024
1 parent bc3aa63 commit 7ce19b8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion scopes/preview/ui/component-preview/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export function ComponentPreview({

useEffect(() => {
const handleLoad = (event) => {
if (event.data && event.data.event === LOAD_EVENT) {
if (event.data && (event.data.event === LOAD_EVENT || event.data.event === 'webpackInvalid')) {
onLoad && onLoad(event);
}
};
Expand Down
4 changes: 4 additions & 0 deletions scopes/react/react/webpack/overlay/webpackHotDevClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ function handleErrors(errors) {
}
}

// only send loaded event when mounted in an iframe
if (window.parent && window !== window.parent) {
window.parent.postMessage({ event: 'webpackInvalid' }, '*');
}
// Do not attempt to reload now.
// We will reload on next success instead.
}
Expand Down

0 comments on commit 7ce19b8

Please sign in to comment.