Skip to content

Commit

Permalink
Exclude existing swc-loader
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinpalkovic committed Nov 20, 2023
1 parent d66e210 commit 3fb18f1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
8 changes: 2 additions & 6 deletions code/builders/builder-webpack5/src/preview/loaders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,8 @@ export const createSWCLoader = async (excludes: string[] = [], options: Options)
};
return {
test: typescriptOptions.skipCompiler ? /\.(mjs|cjs|jsx?)$/ : /\.(mjs|cjs|tsx?|jsx?)$/,
use: [
{
loader: require.resolve('swc-loader'),
options: config,
},
],
loader: require.resolve('swc-loader'),
options: config,
include: [getProjectRoot()],
exclude: [/node_modules/, ...excludes],
};
Expand Down
9 changes: 3 additions & 6 deletions code/frameworks/nextjs/src/swc/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,9 @@ export const configureSWCLoader = async (

baseConfig.module.rules = [
// TODO: Remove filtering in Storybook 8.0
...baseConfig.module.rules.filter(
(r: RuleSetRule) =>
!(typeof r.use === 'object' && 'loader' in r.use && r.use.loader?.includes('swc-loader'))
),
...baseConfig.module.rules.filter((r: RuleSetRule) => {
return !r.loader?.includes('swc-loader');
}),
{
test: /\.(m?(j|t)sx?)$/,
include: [getProjectRoot()],
Expand All @@ -62,14 +61,12 @@ export const configureSWCLoader = async (
pagesDir: `${dir}/pages`,
appDir: `${dir}/apps`,
hasReactRefresh: isDevelopment,
hasServerComponents: true,
nextConfig,
supportedBrowsers: require('next/dist/build/utils').getSupportedBrowsers(
dir,
isDevelopment
),
swcCacheDir: path.join(dir, nextConfig?.distDir ?? '.next', 'cache', 'swc'),
isServerLayer: false,
bundleTarget: 'default',
},
},
Expand Down

0 comments on commit 3fb18f1

Please sign in to comment.