diff --git a/code/lib/builder-webpack5/templates/virtualModuleModernEntry.js.handlebars b/code/lib/builder-webpack5/templates/virtualModuleModernEntry.js.handlebars index 1e9a847ce3e..62b3fe1d603 100644 --- a/code/lib/builder-webpack5/templates/virtualModuleModernEntry.js.handlebars +++ b/code/lib/builder-webpack5/templates/virtualModuleModernEntry.js.handlebars @@ -1,4 +1,4 @@ -import { global } from '@storybook/global'; +import global from 'global'; import { ClientApi, PreviewWeb, addons, composeConfigs } from '@storybook/preview-api'; import { createChannel as createPostMessageChannel } from '@storybook/channel-postmessage'; @@ -9,34 +9,34 @@ import { importFn } from './{{storiesFilename}}'; const { SERVER_CHANNEL_URL } = global; const getProjectAnnotations = () => -composeConfigs([{{#each previewAnnotations}}require('{{this}}'),{{/each}}]); + composeConfigs([{{#each previewAnnotations}}require('{{this}}'),{{/each}}]); const channel = createPostMessageChannel({ page: 'preview' }); addons.setChannel(channel); if (SERVER_CHANNEL_URL) { -const serverChannel = createWebSocketChannel({ url: SERVER_CHANNEL_URL, }); -addons.setServerChannel(serverChannel); -window.__STORYBOOK_SERVER_CHANNEL__ = serverChannel; + const serverChannel = createWebSocketChannel({ url: SERVER_CHANNEL_URL, }); + addons.setServerChannel(serverChannel); + window.__STORYBOOK_SERVER_CHANNEL__ = serverChannel; } -const preview = window.__STORYBOOK_PREVIEW__ || new PreviewWeb(); +const preview = new PreviewWeb(); window.__STORYBOOK_PREVIEW__ = preview; window.__STORYBOOK_STORY_STORE__ = preview.storyStore; window.__STORYBOOK_ADDONS_CHANNEL__ = channel; -window.__STORYBOOK_CLIENT_API__ = window.__STORYBOOK_CLIENT_API__ || new ClientApi({ storyStore: preview.storyStore }); +window.__STORYBOOK_CLIENT_API__ = new ClientApi({ storyStore: preview.storyStore }); preview.initialize({ importFn, getProjectAnnotations }); if (import.meta.webpackHot) { -import.meta.webpackHot.accept('./{{storiesFilename}}', () => { -// importFn has changed so we need to patch the new one in -preview.onStoriesChanged({ importFn }); -}); + import.meta.webpackHot.accept('./{{storiesFilename}}', () => { + // importFn has changed so we need to patch the new one in + preview.onStoriesChanged({ importFn }); + }); -import.meta.webpackHot.accept([{{#each previewAnnotations}}'{{this}}',{{/each}}], () => { -// getProjectAnnotations has changed so we need to patch the new one in -preview.onGetProjectAnnotationsChanged({ getProjectAnnotations }); -}); + import.meta.webpackHot.accept([{{#each previewAnnotations}}'{{this}}',{{/each}}], () => { + // getProjectAnnotations has changed so we need to patch the new one in + preview.onGetProjectAnnotationsChanged({ getProjectAnnotations }); + }); } \ No newline at end of file