Skip to content

Commit c86062a

Browse files
authored
Prevent incompability with 'eval-source-map' and mangle: false (#68688)
Setting the terser option `mangle` to `false` for dev server runtime bundles as done in #68641 seems to be incompatible with `'eval-source-map'`, i.e. when running `pnpm dev`. The combination yields strange runtime errors when running an app with the node runtime. E.g.: ``` ⨯ TypeError: isValidElementType is not a function at renderToHTMLImpl (webpack://next/dist/src/server/render.tsx?e2d9:568:10) at render (webpack://next/dist/src/server/route-modules/pages/module.ts?84fd:125:12) ``` or ``` TypeError: Cannot read properties of undefined (reading 'contexts') at Object.<anonymous> (<snip>/packages/next/src/server/route-modules/pages/vendored/contexts/html-context.ts:1:59) ``` or ``` ⨯ Error: Cannot find module 'next/dist/server/lib/trace/tracer' Require stack: - <snip>/packages/next/dist/compiled/next-server/app-page.runtime.dev.js - <snip>/test/e2e/app-dir/app/.next/server/app/dashboard/page.js ``` Since using `'eval-source-map'` already fixes showing the original names, we don't need to disable mangling in this case. **How to reproduce on `canary`:** - start `pnpm dev` - start `pnpm next dev test/e2e/app-dir/app` - open http://localhost:3000/client-component-route - observe errors
1 parent 20e3b77 commit c86062a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

packages/next/webpack.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,8 @@ module.exports = ({ dev, turbo, bundleType, experimental }) => {
173173
format: {
174174
preamble: '',
175175
},
176-
mangle: dev ? false : true,
176+
mangle:
177+
dev && !process.env.NEXT_SERVER_EVAL_SOURCE_MAPS ? false : true,
177178
},
178179
}),
179180
],

0 commit comments

Comments
 (0)