Skip to content

Commit 06b3056

Browse files
committed
improve readability of case when matching internal virtual files.
1 parent 2983993 commit 06b3056

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

code/builders/builder-vite/src/plugins/webpack-stats-plugin.ts

+13-7
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,20 @@ function stripQueryParams(filePath: string): string {
4040

4141
/** We only care about user code, not node_modules, vite files, or (most) virtual files. */
4242
function isUserCode(moduleName: string) {
43+
if (!moduleName) {
44+
return false;
45+
}
46+
47+
// keep Storybook's virtual files because they import the story files, so they are essential to the module graph
48+
if (Object.values(SB_VIRTUAL_FILES).includes(getOriginalVirtualModuleId(moduleName))) {
49+
return true;
50+
}
51+
4352
return Boolean(
44-
(moduleName &&
45-
// keep Storybook's virtual files because they import the story files, so they are essential to the module graph
46-
Object.values(SB_VIRTUAL_FILES).includes(getOriginalVirtualModuleId(moduleName))) ||
47-
(!moduleName.startsWith('vite/') &&
48-
!moduleName.startsWith('\0') &&
49-
moduleName !== 'react/jsx-runtime' &&
50-
!moduleName.match(/node_modules\//))
53+
!moduleName.startsWith('vite/') &&
54+
!moduleName.startsWith('\0') &&
55+
moduleName !== 'react/jsx-runtime' &&
56+
!moduleName.match(/node_modules\//)
5157
);
5258
}
5359

0 commit comments

Comments
 (0)