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

Account for rsbuild stats JSON output and multiple locations #1110

Merged
merged 1 commit into from
Nov 4, 2024
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
5 changes: 4 additions & 1 deletion node-src/lib/getDependentStoryFiles.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,10 @@ describe('getDependentStoryFiles', () => {
id: String.raw`./src lazy recursive ^\.\/.*$`,
reasons: [
{
moduleName: './node_modules/.cache/storybook/default/dev-server/storybook-stories.js',
resolvedModule:
jmhobbs marked this conversation as resolved.
Show resolved Hide resolved
'./node_modules/.cache/storybook/default/dev-server/storybook-stories.js',
moduleName:
'./node_modules/.cache/storybook/default/dev-server/storybook-stories.js + 2 modules',
},
],
},
Expand Down
9 changes: 8 additions & 1 deletion node-src/lib/getDependentStoryFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const getPackageName = (modulePath: string) => {
*/
export function normalizePath(posixPath: string, rootPath: string, baseDirectory = '') {
if (!posixPath || posixPath.startsWith('/virtual:')) return posixPath;

return path.posix.isAbsolute(posixPath)
? path.posix.relative(rootPath, posixPath)
: path.posix.join(baseDirectory, posixPath);
Expand Down Expand Up @@ -140,6 +141,7 @@ export async function getDependentStoryFiles(
`/virtual:/@storybook/builder-vite/vite-app.js`,
// rspack builder
`./node_modules/.cache/storybook/default/dev-server/storybook-stories.js`,
`./node_modules/.cache/storybook/storybook-rsbuild-builder/storybook-config-entry.js`,
].map((file) => normalize(file))
);

Expand Down Expand Up @@ -172,7 +174,12 @@ export async function getDependentStoryFiles(
}

const normalizedReasons = module_.reasons
?.map((reason) => normalize(reason.moduleName))
?.map((reason) =>
normalize(
reason.resolvedModule || // rspack sets a resolvedModule that holds the module name
reason.moduleName // vite, webpack, and default
)
)
.filter((reasonName) => reasonName && reasonName !== normalizedName);
if (normalizedReasons) {
reasonsById.set(module_.id, normalizedReasons);
Expand Down
1 change: 1 addition & 0 deletions node-src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ export interface Task {
}

export interface Reason {
resolvedModule?: string; // rspack sets a resolvedModule field that holds the module name
moduleName: string;
}
export interface Module {
Expand Down
Loading