Skip to content

Commit 3e4f886

Browse files
committed
Gate the webpack opt-out at Next >= 16, not >= 15
`next build --webpack` was added in Next 16 (when Turbopack became the build default); Next 15 builds with webpack already and errors on the unknown flag, which would break `mailing server build` for Next 15 users. Same for the programmatic dev server's `webpack: true` (only needed on Next 16, whose dev server defaults to Turbopack). Threshold corrected 15 -> 16.
1 parent 5e8736c commit 3e4f886

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

packages/cli/src/commands/preview/server/start.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ export default async function startPreviewServer() {
5555

5656
// Next 16 defaults the dev server to Turbopack, which can't resolve some of
5757
// the preview app's dynamic dependencies (e.g. uglify-js) and returns 500s.
58-
// Force webpack on Next >= 15, where a custom server may pass this option;
59-
// older Next uses webpack by default. See gh#504.
60-
if (nextMajorVersion() >= 15) nextOptions.webpack = true;
58+
// Force webpack on Next >= 16, where a custom server may pass this option;
59+
// Next <= 15 uses webpack by default and ignores the option. See gh#504.
60+
if (nextMajorVersion() >= 16) nextOptions.webpack = true;
6161

6262
const app = next(nextOptions);
6363
const nextHandle = app.getRequestHandler();

packages/cli/src/commands/server.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,11 @@ export const builder = {
4242
// Next 16 makes `next build` use Turbopack by default, whose static analysis
4343
// can't follow the .mailing preview app's dynamic requires (e.g. the generated
4444
// Prisma client), so the build fails ("Encountered unexpected file in NFT
45-
// list" / EBADF). Opt back into webpack on Next >= 15, where the `--webpack`
46-
// flag exists; older Next versions build with webpack by default. See gh#504.
45+
// list" / EBADF). Opt back into webpack on Next >= 16, where the `--webpack`
46+
// flag was added; Next <= 15 builds with webpack by default and errors on the
47+
// unknown flag. See gh#504.
4748
function nextBuildBundlerFlag(): string {
48-
return nextMajorVersion() >= 15 ? " --webpack" : "";
49+
return nextMajorVersion() >= 16 ? " --webpack" : "";
4950
}
5051

5152
export const handler = buildHandler(async (argv: ServerArguments) => {

0 commit comments

Comments
 (0)