Skip to content

Commit

Permalink
fix opt out packages
Browse files Browse the repository at this point in the history
  • Loading branch information
shuding committed Sep 26, 2022
1 parent a2f21cf commit 6c3c839
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion packages/next/build/webpack-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1133,7 +1133,20 @@ export default async function getBaseWebpackConfig(

if (/node_modules[/\\].*\.[mc]?js$/.test(res)) {
if (layer === WEBPACK_LAYERS.server) {
// All packages should be bundled for the server layer
// All packages should be bundled for the server layer if they're not opted out.
if (
config.experimental.optoutServerComponentsBundle?.some(
(p: string) => {
return (
res.includes('node_modules/' + p + '/') ||
res.includes('node_modules\\' + p + '\\')
)
}
)
) {
return `${externalType} ${request}`
}

return
}

Expand Down Expand Up @@ -1495,6 +1508,18 @@ export default async function getBaseWebpackConfig(
? [
{
issuerLayer: WEBPACK_LAYERS.server,
test: (req: string) => {
if (
config.experimental.optoutServerComponentsBundle?.some(
(mod) => {
return req.includes('/node_modules/' + mod + '/')
}
)
) {
return false
}
return true
},
resolve: process.env.__NEXT_REACT_CHANNEL
? {
conditionNames: ['react-server'],
Expand Down

0 comments on commit 6c3c839

Please sign in to comment.