From 1606dd0ec0142a95dce0117f0823815f9f762358 Mon Sep 17 00:00:00 2001 From: Michael Shilman Date: Fri, 14 Apr 2023 10:26:05 +0800 Subject: [PATCH] Core: Guard against webpack HMR decline in non-webpack environments --- code/frameworks/angular/src/client/index.ts | 2 +- code/frameworks/ember/src/index.ts | 2 +- code/renderers/html/src/index.ts | 2 +- code/renderers/preact/src/index.ts | 2 +- code/renderers/react/src/index.ts | 2 +- code/renderers/server/src/index.ts | 2 +- code/renderers/svelte/src/index.ts | 2 +- code/renderers/vue/src/index.ts | 2 +- code/renderers/vue3/src/index.ts | 2 +- code/renderers/web-components/src/index.ts | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/code/frameworks/angular/src/client/index.ts b/code/frameworks/angular/src/client/index.ts index 04e9244b1314..bfc209efb4d4 100644 --- a/code/frameworks/angular/src/client/index.ts +++ b/code/frameworks/angular/src/client/index.ts @@ -12,4 +12,4 @@ export type { StoryFnAngularReturnType as IStory } from './types'; export { moduleMetadata, componentWrapperDecorator, applicationConfig } from './decorators'; // optimization: stop HMR propagation in webpack -module?.hot?.decline(); +if (typeof module !== 'undefined') module?.hot?.decline(); diff --git a/code/frameworks/ember/src/index.ts b/code/frameworks/ember/src/index.ts index db22918233c3..3d30d71982e6 100644 --- a/code/frameworks/ember/src/index.ts +++ b/code/frameworks/ember/src/index.ts @@ -3,4 +3,4 @@ export { storiesOf, configure, forceReRender, raw } from './client/preview'; // optimization: stop HMR propagation in webpack -module?.hot?.decline(); +if (typeof module !== 'undefined') module?.hot?.decline(); diff --git a/code/renderers/html/src/index.ts b/code/renderers/html/src/index.ts index 9d5afe665e9a..0c37ede8d826 100644 --- a/code/renderers/html/src/index.ts +++ b/code/renderers/html/src/index.ts @@ -6,4 +6,4 @@ export * from './public-api'; export * from './public-types'; // optimization: stop HMR propagation in webpack -module?.hot?.decline(); +if (typeof module !== 'undefined') module?.hot?.decline(); diff --git a/code/renderers/preact/src/index.ts b/code/renderers/preact/src/index.ts index 9d5afe665e9a..0c37ede8d826 100644 --- a/code/renderers/preact/src/index.ts +++ b/code/renderers/preact/src/index.ts @@ -6,4 +6,4 @@ export * from './public-api'; export * from './public-types'; // optimization: stop HMR propagation in webpack -module?.hot?.decline(); +if (typeof module !== 'undefined') module?.hot?.decline(); diff --git a/code/renderers/react/src/index.ts b/code/renderers/react/src/index.ts index 68dae468dcc1..ae032e4f06b8 100644 --- a/code/renderers/react/src/index.ts +++ b/code/renderers/react/src/index.ts @@ -8,4 +8,4 @@ export * from './public-types'; export * from './testing-api'; // optimization: stop HMR propagation in webpack -module?.hot?.decline(); +if (typeof module !== 'undefined') module?.hot?.decline(); diff --git a/code/renderers/server/src/index.ts b/code/renderers/server/src/index.ts index 9d5afe665e9a..0c37ede8d826 100644 --- a/code/renderers/server/src/index.ts +++ b/code/renderers/server/src/index.ts @@ -6,4 +6,4 @@ export * from './public-api'; export * from './public-types'; // optimization: stop HMR propagation in webpack -module?.hot?.decline(); +if (typeof module !== 'undefined') module?.hot?.decline(); diff --git a/code/renderers/svelte/src/index.ts b/code/renderers/svelte/src/index.ts index 9d5afe665e9a..0c37ede8d826 100644 --- a/code/renderers/svelte/src/index.ts +++ b/code/renderers/svelte/src/index.ts @@ -6,4 +6,4 @@ export * from './public-api'; export * from './public-types'; // optimization: stop HMR propagation in webpack -module?.hot?.decline(); +if (typeof module !== 'undefined') module?.hot?.decline(); diff --git a/code/renderers/vue/src/index.ts b/code/renderers/vue/src/index.ts index 9d5afe665e9a..0c37ede8d826 100644 --- a/code/renderers/vue/src/index.ts +++ b/code/renderers/vue/src/index.ts @@ -6,4 +6,4 @@ export * from './public-api'; export * from './public-types'; // optimization: stop HMR propagation in webpack -module?.hot?.decline(); +if (typeof module !== 'undefined') module?.hot?.decline(); diff --git a/code/renderers/vue3/src/index.ts b/code/renderers/vue3/src/index.ts index 9d5afe665e9a..0c37ede8d826 100644 --- a/code/renderers/vue3/src/index.ts +++ b/code/renderers/vue3/src/index.ts @@ -6,4 +6,4 @@ export * from './public-api'; export * from './public-types'; // optimization: stop HMR propagation in webpack -module?.hot?.decline(); +if (typeof module !== 'undefined') module?.hot?.decline(); diff --git a/code/renderers/web-components/src/index.ts b/code/renderers/web-components/src/index.ts index 4234d00e0726..044e7875f24c 100644 --- a/code/renderers/web-components/src/index.ts +++ b/code/renderers/web-components/src/index.ts @@ -11,7 +11,7 @@ export * from './public-api'; export * from './framework-api'; // TODO: disable HMR and do full page loads because of customElements.define -if (module && module.hot && module.hot.decline) { +if (typeof module !== 'undefined' && module?.hot?.decline) { module.hot.decline(); // forcing full reloads for customElements as elements can only be defined once per page