Fix import url on windows

This commit is contained in:
Han Yeong-woo 2022-12-25 03:44:13 +09:00 committed by Valentin Palkovic
parent 8f6d23a2ab
commit d61cfc1555
2 changed files with 7 additions and 5 deletions

View File

@ -1,6 +1,7 @@
import { join, parse, relative } from 'path';
import fs from 'fs-extra';
import findCacheDirectory from 'find-cache-dir';
import fs from 'fs-extra';
import { join, parse, relative } from 'node:path';
import slash from 'slash';
/**
* Manager entries should be **self-invoking** bits of code.
* They can of-course import from modules, and ESbuild will bundle all of that into a single file.
@ -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;
})

View File

@ -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<Builder<unknown>> {
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;
}