diff --git a/templates/virtualModuleModernEntry.js.handlebars b/templates/virtualModuleModernEntry.js.handlebars index 30df5e4c42489b58e5dbca0402bf1f5d35f27a61..13bc5ae24a8db553999a72dca3104b16086a732d 100644 --- a/templates/virtualModuleModernEntry.js.handlebars +++ b/templates/virtualModuleModernEntry.js.handlebars @@ -11,8 +11,9 @@ import { importFn } from './{{storiesFilename}}'; const { SERVER_CHANNEL_URL } = global; -const getProjectAnnotations = () => - composeConfigs([{{#each configs}}require('{{this}}'),{{/each}}]); +// patch from https://github.com/storybookjs/storybook/pull/17108/commits/cde08674427f005aafc63a4cec7a216217974f53 +const getProjectAnnotations = async () => + composeConfigs(await Promise.all([{{#each configs}}import('{{this}}'),{{/each}}])); const channel = createPostMessageChannel({ page: 'preview' }); addons.setChannel(channel); @@ -32,7 +33,8 @@ window.__STORYBOOK_CLIENT_API__ = new ClientApi({ storyStore: preview.storyStore preview.initialize({ importFn, getProjectAnnotations }); -if (module.hot) { +// patch from https://github.com/storybookjs/storybook/pull/19686/commits/2f676a2528a2baf1fdf9063642b9621a2fe3d566 +if (import.meta.webpackHot) { import.meta.webpackHot.accept('./{{storiesFilename}}', () => { // importFn has changed so we need to patch the new one in preview.onStoriesChanged({ importFn });