Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix import paths on Windows #20430

Merged
merged 3 commits into from
Dec 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
valentinpalkovic marked this conversation as resolved.
Show resolved Hide resolved
}
),
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