Unverified Commit 8a1717cb authored by Jiachi Liu's avatar Jiachi Liu Committed by GitHub

Rename confusing loaders (#59827)

We already have variables of swc loaders for different bundling layers,
the composed one should just be loaders instead of being called "swc
loader"

Closes NEXT-1917
parent 1affa75a
......@@ -468,7 +468,7 @@ export default async function getBaseWebpackConfig(
babel: useSWCLoader ? swcDefaultLoader : babelLoader!,
}
const swcLoaderForServerLayer = hasAppDir
const appServerLayerLoaders = hasAppDir
? [
// When using Babel, we will have to add the SWC loader
// as an additional pass to handle RSC correctly.
......@@ -479,7 +479,7 @@ export default async function getBaseWebpackConfig(
].filter(Boolean)
: []
const swcLoaderForMiddlewareLayer = [
const middlewareLayerLoaders = [
// When using Babel, we will have to use SWC to do the optimization
// for middleware to tree shake the unused default optimized imports like "next/server".
// This will cause some performance overhead but
......@@ -495,7 +495,7 @@ export default async function getBaseWebpackConfig(
dev && isClient ? [require.resolve(reactRefreshLoaderName)] : []
// client components layers: SSR or browser
const createSwcLoaderForClientLayer = ({
const createClientLayerLoader = ({
isBrowserLayer,
reactRefresh,
}: {
......@@ -520,12 +520,12 @@ export default async function getBaseWebpackConfig(
: []),
]
const swcLoaderForBrowserLayer = createSwcLoaderForClientLayer({
const appBrowserLayerLoaders = createClientLayerLoader({
isBrowserLayer: true,
// reactRefresh for browser layer is applied conditionally to user-land source
reactRefresh: false,
})
const swcLoaderForSSRLayer = createSwcLoaderForClientLayer({
const appSSRLayerLoaders = createClientLayerLoader({
isBrowserLayer: false,
reactRefresh: true,
})
......@@ -533,7 +533,7 @@ export default async function getBaseWebpackConfig(
// Loader for API routes needs to be differently configured as it shouldn't
// have RSC transpiler enabled, so syntax checks such as invalid imports won't
// be performed.
const loaderForAPIRoutes =
const apiRoutesLayerLoaders =
hasAppDir && useSWCLoader
? getSwcLoader({
serverComponents: false,
......@@ -1415,12 +1415,12 @@ export default async function getBaseWebpackConfig(
// Switch back to normal URL handling
url: true,
},
use: loaderForAPIRoutes,
use: apiRoutesLayerLoaders,
},
{
test: codeCondition.test,
issuerLayer: WEBPACK_LAYERS.middleware,
use: swcLoaderForMiddlewareLayer,
use: middlewareLayerLoaders,
},
...(hasAppDir
? [
......@@ -1428,19 +1428,19 @@ export default async function getBaseWebpackConfig(
test: codeCondition.test,
issuerLayer: isWebpackServerLayer,
exclude: asyncStoragesRegex,
use: swcLoaderForServerLayer,
use: appServerLayerLoaders,
},
{
test: codeCondition.test,
resourceQuery: new RegExp(
WEBPACK_RESOURCE_QUERIES.edgeSSREntry
),
use: swcLoaderForServerLayer,
use: appServerLayerLoaders,
},
{
test: codeCondition.test,
issuerLayer: WEBPACK_LAYERS.appPagesBrowser,
use: swcLoaderForBrowserLayer,
use: appBrowserLayerLoaders,
resolve: {
mainFields: getMainField(compilerType, true),
},
......@@ -1448,7 +1448,7 @@ export default async function getBaseWebpackConfig(
{
test: codeCondition.test,
issuerLayer: WEBPACK_LAYERS.serverSideRendering,
use: swcLoaderForSSRLayer,
use: appSSRLayerLoaders,
resolve: {
mainFields: getMainField(compilerType, true),
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment