Skip to content

Commit

Permalink
fix: 🐛 attach devClientHook only if entry point exists
Browse files Browse the repository at this point in the history
  • Loading branch information
mjancarik committed Nov 13, 2024
1 parent b101175 commit 0152316
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions packages/cli/src/devClient/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ webSocket.subscribe(reload);
webSocket.subscribe(hmr);

addEventListener('load', function hookMerkurCreate() {
const originalMerkurCreate = window.__merkur__.create;
window.__merkur__.create = async function devClientHook(...rest) {
const widget = await originalMerkurCreate(...rest);
if (window?.__merkur__?.create) {
const originalMerkurCreate = window.__merkur__.create;
window.__merkur__.create = async function devClientHook(...rest) {
const widget = await originalMerkurCreate(...rest);

__merkur_dev__.widgets.push(widget);
__merkur_dev__.widgets.push(widget);

return widget;
};
return widget;
};
}
});

0 comments on commit 0152316

Please sign in to comment.