Skip to content

Commit

Permalink
improve readability of case when matching internal virtual files.
Browse files Browse the repository at this point in the history
  • Loading branch information
JReinhold committed Sep 9, 2024
1 parent 2983993 commit 06b3056
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions code/builders/builder-vite/src/plugins/webpack-stats-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,20 @@ function stripQueryParams(filePath: string): string {

/** We only care about user code, not node_modules, vite files, or (most) virtual files. */
function isUserCode(moduleName: string) {
if (!moduleName) {
return false;
}

// keep Storybook's virtual files because they import the story files, so they are essential to the module graph
if (Object.values(SB_VIRTUAL_FILES).includes(getOriginalVirtualModuleId(moduleName))) {
return true;
}

return Boolean(
(moduleName &&
// keep Storybook's virtual files because they import the story files, so they are essential to the module graph
Object.values(SB_VIRTUAL_FILES).includes(getOriginalVirtualModuleId(moduleName))) ||
(!moduleName.startsWith('vite/') &&
!moduleName.startsWith('\0') &&
moduleName !== 'react/jsx-runtime' &&
!moduleName.match(/node_modules\//))
!moduleName.startsWith('vite/') &&
!moduleName.startsWith('\0') &&
moduleName !== 'react/jsx-runtime' &&
!moduleName.match(/node_modules\//)
);
}

Expand Down

0 comments on commit 06b3056

Please sign in to comment.