Skip to content

Commit

Permalink
Apply react-server transform and valication to middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi committed Oct 25, 2023
1 parent 7274296 commit 77af7c2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
8 changes: 4 additions & 4 deletions packages/next/src/build/webpack-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -461,17 +461,17 @@ export default async function getBaseWebpackConfig(

const swcLoaderForMiddlewareLayer = useSWCLoader
? getSwcLoader({
serverComponents: false,
isReactServerLayer: false,
serverComponents: true,
isReactServerLayer: true,
})
: // 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
// acceptable as Babel will not be recommended.
[
getSwcLoader({
serverComponents: false,
isReactServerLayer: false,
serverComponents: true,
isReactServerLayer: true,
}),
getBabelLoader(),
]
Expand Down
5 changes: 1 addition & 4 deletions packages/next/src/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,9 @@ const WEBPACK_LAYERS = {
WEBPACK_LAYERS_NAMES.actionBrowser,
WEBPACK_LAYERS_NAMES.appMetadataRoute,
WEBPACK_LAYERS_NAMES.appRouteHandler,
],
nonClientServerTarget: [
// plus middleware and pages api
WEBPACK_LAYERS_NAMES.middleware,
WEBPACK_LAYERS_NAMES.api,
],
nonClientServerTarget: [WEBPACK_LAYERS_NAMES.api],
app: [
WEBPACK_LAYERS_NAMES.reactServerComponents,
WEBPACK_LAYERS_NAMES.actionBrowser,
Expand Down

0 comments on commit 77af7c2

Please sign in to comment.