diff --git a/code/lib/builder-manager/src/utils/managerEntries.ts b/code/lib/builder-manager/src/utils/managerEntries.ts index f6e85efaec5d..8794897ef7e4 100644 --- a/code/lib/builder-manager/src/utils/managerEntries.ts +++ b/code/lib/builder-manager/src/utils/managerEntries.ts @@ -1,5 +1,6 @@ -import { join, parse, relative } from 'path'; import fs from 'fs-extra'; +import { join, parse, relative } from 'node:path'; +import slash from 'slash'; import findCacheDirectory from 'find-cache-dir'; /** * Manager entries should be **self-invoking** bits of code. @@ -29,7 +30,7 @@ export async function wrapManagerEntries(entrypoints: string[]) { const location = join(cacheLocation, relative(process.cwd(), dir), `${name}-bundle.mjs`); await fs.ensureFile(location); - await fs.writeFile(location, `import '${entry}';`); + await fs.writeFile(location, `import '${slash(entry)}';`); return location; }) diff --git a/code/lib/builder-webpack5/src/preview/iframe-webpack.config.ts b/code/lib/builder-webpack5/src/preview/iframe-webpack.config.ts index 02be5f0053fd..cb85f840dc5e 100644 --- a/code/lib/builder-webpack5/src/preview/iframe-webpack.config.ts +++ b/code/lib/builder-webpack5/src/preview/iframe-webpack.config.ts @@ -7,6 +7,7 @@ import CaseSensitivePathsPlugin from 'case-sensitive-paths-webpack-plugin'; import TerserWebpackPlugin from 'terser-webpack-plugin'; import VirtualModulePlugin from 'webpack-virtual-modules'; import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin'; +import slash from 'slash'; import type { Options, CoreConfig, DocsOptions, PreviewAnnotation } from '@storybook/types'; import { globals } from '@storybook/preview/globals'; @@ -108,7 +109,7 @@ export default async ( if (typeof entry === 'object') { return entry.absolute; } - return entry; + return slash(entry); } ), loadPreviewOrConfigFile(options), diff --git a/code/lib/core-server/src/utils/get-builders.ts b/code/lib/core-server/src/utils/get-builders.ts index 11ee9514a2d6..9f71b5e085a5 100644 --- a/code/lib/core-server/src/utils/get-builders.ts +++ b/code/lib/core-server/src/utils/get-builders.ts @@ -1,4 +1,5 @@ -import type { Options, CoreConfig, Builder } from '@storybook/types'; +import type { Builder, CoreConfig, Options } from '@storybook/types'; +import { pathToFileURL } from 'node:url'; export async function getManagerBuilder(): Promise> { return import('@storybook/builder-manager'); @@ -17,7 +18,7 @@ export async function getPreviewBuilder( } else { throw new Error('no builder configured!'); } - const previewBuilder = await import(builderPackage); + const previewBuilder = await import(pathToFileURL(builderPackage).href); return previewBuilder; }