Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SWC loader options for files outside of RSC layers #50341

Merged
merged 2 commits into from
May 25, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions packages/next/src/build/webpack-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,6 @@ export default async function getBaseWebpackConfig(
rootDir: dir,
pagesDir,
appDir,
hasServerComponents,
huozhi marked this conversation as resolved.
Show resolved Hide resolved
hasReactRefresh: dev && isClient,
fileReading: config.experimental.swcFileReading,
nextConfig: config,
Expand All @@ -865,7 +864,7 @@ export default async function getBaseWebpackConfig(

const swcLoaderForServerLayer = hasServerComponents
? useSWCLoader
? [getSwcLoader({ isServerLayer: true })]
? [getSwcLoader({ hasServerComponents, isServerLayer: true })]
: // When using Babel, we will have to add the SWC loader
// as an additional pass to handle RSC correctly.
// This will cause some performance overhead but
Expand All @@ -874,12 +873,15 @@ export default async function getBaseWebpackConfig(
: []
const swcLoaderForClientLayer = hasServerComponents
? useSWCLoader
? [getSwcLoader({ isServerLayer: false })]
? [getSwcLoader({ hasServerComponents, isServerLayer: false })]
: // When using Babel, we will have to add the SWC loader
// as an additional pass to handle RSC correctly.
// This will cause some performance overhead but
// acceptable as Babel will not be recommended.
[getSwcLoader({ isServerLayer: false }), getBabelLoader()]
[
getSwcLoader({ hasServerComponents, isServerLayer: false }),
getBabelLoader(),
]
: []

// Loader for API routes needs to be differently configured as it shouldn't
Expand Down