Skip to content

Commit

Permalink
Merge pull request #20430 from storybookjs/fix-windows-issue
Browse files Browse the repository at this point in the history
Fix import paths on Windows
  • Loading branch information
valentinpalkovic authored Dec 30, 2022
2 parents 1cf5f17 + 0013e99 commit 1727d4b
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
7 changes: 4 additions & 3 deletions code/lib/builder-manager/src/utils/managerEntries.ts
Original file line number Diff line number Diff line change
@@ -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.
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
1 change: 1 addition & 0 deletions code/lib/builder-webpack5/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
"path-browserify": "^1.0.1",
"process": "^0.11.10",
"semver": "^7.3.7",
"slash": "^5.0.0",
"style-loader": "^3.3.1",
"terser-webpack-plugin": "^5.3.1",
"ts-dedent": "^2.0.0",
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
1 change: 1 addition & 0 deletions code/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6114,6 +6114,7 @@ __metadata:
pretty-hrtime: ^1.0.3
process: ^0.11.10
semver: ^7.3.7
slash: ^5.0.0
style-loader: ^3.3.1
terser-webpack-plugin: ^5.3.1
ts-dedent: ^2.0.0
Expand Down

0 comments on commit 1727d4b

Please sign in to comment.