Skip to content

Commit

Permalink
Fix import paths on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinpalkovic committed Dec 29, 2022
1 parent 8f6d23a commit 0982f0b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
5 changes: 3 additions & 2 deletions code/lib/builder-manager/src/utils/managerEntries.ts
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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;
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -108,7 +109,7 @@ export default async (
if (typeof entry === 'object') {
return entry.absolute;
}
return entry;
return slash(entry);
}
),
loadPreviewOrConfigFile(options),
Expand Down
5 changes: 3 additions & 2 deletions code/lib/core-server/src/utils/get-builders.ts
Original file line number Diff line number Diff line change
@@ -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');
Expand All @@ -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;
}

Expand Down

0 comments on commit 0982f0b

Please sign in to comment.