|
| 1 | +diff --git a/gen-preview-modern.js b/gen-preview-modern.js |
| 2 | +index a1fe3d1ce6b748e533200f5af69a0481e5809c6c..aeed09de7dbaddd4606ac3579a86cb2ba389eb2f 100644 |
| 3 | +--- a/gen-preview-modern.js |
| 4 | ++++ b/gen-preview-modern.js |
| 5 | +@@ -7,9 +7,16 @@ const { |
| 6 | + } = require("@storybook/core-common"); |
| 7 | + const { logger } = require("@storybook/node-logger"); |
| 8 | + const { promise: glob } = require("glob-promise"); |
| 9 | ++const isMingw = require('is-mingw'); |
| 10 | + |
| 11 | +-const absoluteToSpecifier = (generatedEntries, abs) => |
| 12 | +- "./" + path.relative(generatedEntries, abs); |
| 13 | ++const absoluteToSpecifier = (generatedEntries, abs) => { |
| 14 | ++ let relativePath = path.relative(generatedEntries, abs); |
| 15 | ++ if (isMingw()) { |
| 16 | ++ relativePath = relativePath.replace(/\\/g, '/'); |
| 17 | ++ } |
| 18 | ++ |
| 19 | ++ return "./" + relativePath; |
| 20 | ++} |
| 21 | + |
| 22 | + module.exports.generatePreviewModern = async function generatePreviewModern( |
| 23 | + options, |
| 24 | +@@ -66,7 +73,7 @@ module.exports.generatePreviewModern = async function generatePreviewModern( |
| 25 | + */ |
| 26 | + const code = ` |
| 27 | + import { composeConfigs, PreviewWeb, ClientApi } from '@storybook/preview-api'; |
| 28 | +- |
| 29 | ++ |
| 30 | + // generateAddonSetupCode |
| 31 | + import { createBrowserChannel } from '@storybook/channels'; |
| 32 | + import { addons } from '@storybook/preview-api'; |
| 33 | +@@ -94,7 +101,7 @@ module.exports.generatePreviewModern = async function generatePreviewModern( |
| 34 | + window.__STORYBOOK_CLIENT_API__ = new ClientApi({ storyStore: preview.storyStore }); |
| 35 | + |
| 36 | + preview.initialize({ importFn, getProjectAnnotations }); |
| 37 | +- |
| 38 | ++ |
| 39 | + `; |
| 40 | + // ${generateHMRHandler(frameworkName)}; |
| 41 | + return code; |
| 42 | +@@ -152,7 +159,11 @@ function toImportPath(relativePath) { |
| 43 | + async function toImportFn(stories, generatedEntries) { |
| 44 | + const objectEntries = stories.map((file) => { |
| 45 | + const ext = path.extname(file); |
| 46 | +- const relativePath = /*normalizePath*/ path.relative(process.cwd(), file); |
| 47 | ++ let relativePath = /*normalizePath*/ path.relative(process.cwd(), file); |
| 48 | ++ if (isMingw()) { |
| 49 | ++ relativePath = relativePath.replace(/\\/g, '/'); |
| 50 | ++ } |
| 51 | ++ |
| 52 | + if (![".js", ".jsx", ".ts", ".tsx", ".mdx"].includes(ext)) { |
| 53 | + logger.warn( |
| 54 | + `Cannot process ${ext} file with storyStoreV7: ${relativePath}` |
0 commit comments