Skip to content

Commit

Permalink
Merge pull request #22085 from storybookjs/shilman/22046-typeof-module
Browse files Browse the repository at this point in the history
Core: Fix `module` guard in non-webpack environments
  • Loading branch information
valentinpalkovic authored and shilman committed Apr 18, 2023
1 parent 681e1d4 commit 5517dac
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion code/frameworks/angular/src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
2 changes: 1 addition & 1 deletion code/frameworks/ember/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
2 changes: 1 addition & 1 deletion code/renderers/html/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
2 changes: 1 addition & 1 deletion code/renderers/preact/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
2 changes: 1 addition & 1 deletion code/renderers/react/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
2 changes: 1 addition & 1 deletion code/renderers/server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
2 changes: 1 addition & 1 deletion code/renderers/svelte/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
2 changes: 1 addition & 1 deletion code/renderers/vue/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
2 changes: 1 addition & 1 deletion code/renderers/vue3/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
2 changes: 1 addition & 1 deletion code/renderers/web-components/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5517dac

Please sign in to comment.