diff --git a/node-src/lib/getDependentStoryFiles.test.ts b/node-src/lib/getDependentStoryFiles.test.ts index 55fe8f790..2b3d73a24 100644 --- a/node-src/lib/getDependentStoryFiles.test.ts +++ b/node-src/lib/getDependentStoryFiles.test.ts @@ -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: + './node_modules/.cache/storybook/default/dev-server/storybook-stories.js', + moduleName: + './node_modules/.cache/storybook/default/dev-server/storybook-stories.js + 2 modules', }, ], }, diff --git a/node-src/lib/getDependentStoryFiles.ts b/node-src/lib/getDependentStoryFiles.ts index 94c44e493..d0940ca78 100644 --- a/node-src/lib/getDependentStoryFiles.ts +++ b/node-src/lib/getDependentStoryFiles.ts @@ -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); @@ -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)) ); @@ -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); diff --git a/node-src/types.ts b/node-src/types.ts index 8e34eab82..1e39a0f1d 100644 --- a/node-src/types.ts +++ b/node-src/types.ts @@ -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 {