Skip to content

Commit

Permalink
Merge pull request #22331 from storybookjs/norbert/fix-22300
Browse files Browse the repository at this point in the history
Fix: virtual modules excluded for babel-loader
  • Loading branch information
tmeasday authored and shilman committed May 5, 2023
1 parent 10771fc commit 74eebc2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions code/lib/builder-webpack5/src/preview/babel-loader-preview.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { getProjectRoot } from '@storybook/core-common';
import type { TypescriptOptions } from '../types';

export const createBabelLoader = (options: any, typescriptOptions: TypescriptOptions) => {
export const createBabelLoader = (
options: any,
typescriptOptions: TypescriptOptions,
excludes: string[] = []
) => {
return {
test: typescriptOptions.skipBabel ? /\.(mjs|jsx?)$/ : /\.(mjs|tsx?|jsx?)$/,
use: [
Expand All @@ -11,6 +15,6 @@ export const createBabelLoader = (options: any, typescriptOptions: TypescriptOpt
},
],
include: [getProjectRoot()],
exclude: /node_modules/,
exclude: [/node_modules/, ...excludes],
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ export default async (
fullySpecified: false,
},
},
createBabelLoader(babelOptions, typescriptOptions),
createBabelLoader(babelOptions, typescriptOptions, Object.keys(virtualModuleMapping)),
{
test: /\.md$/,
type: 'asset/source',
Expand Down

0 comments on commit 74eebc2

Please sign in to comment.