Skip to content

Commit e3ebfef

Browse files
committed
Ensure original variable names are shown when debugging node runtime
Using `eval-source-map` also allows us to revert the disabling of `preloadEntries` when debugging.
1 parent 0439d94 commit e3ebfef

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

contributing/core/vscode-debugger.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ Any Next.js app inside the monorepo can be debugged with these configurations.
1818
2. Enter the app dirname, e.g. `examples/hello-world` or `test/e2e/app-dir/app`.
1919
3. Select the `next` command from the presented options (`dev`, `build`, or `start`).
2020

21-
To see the changes you make to the Next.js codebase during development, you can run `pnpm dev` in the root directory, which will watch for file changes in `packages/next` and recompile the Next.js source code on any file saves.
21+
To see the changes you make to the Next.js codebase during development, you can run `NEXT_SERVER_EVAL_SOURCE_MAPS=1 pnpm dev` in the root directory, which will watch for file changes in `packages/next` and recompile the Next.js source code on any file saves.
2222

2323
## Breakpoints
2424

2525
When developing/debugging Next.js, you can set breakpoints anywhere in the `packages/next` source code that will stop the debugger at certain locations so you can examine the behavior. Read more about [breakpoints in the VS Code documentation](https://code.visualstudio.com/docs/nodejs/nodejs-debugging#_breakpoints).
26+
27+
To ensure that the original names are displayed in the "Variables" section, build the Next.js source code with `NEXT_SERVER_EVAL_SOURCE_MAPS=1` (see above).

packages/next/src/server/next-server.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,6 @@ export default class NextNodeServer extends BaseServer<
231231

232232
if (
233233
!options.dev &&
234-
!options.isNodeDebugging &&
235234
!this.minimalMode &&
236235
this.nextConfig.experimental.preloadEntriesOnStart
237236
) {

packages/next/webpack.config.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,9 @@ module.exports = ({ dev, turbo, bundleType, experimental }) => {
152152
}.runtime.${dev ? 'dev' : 'prod'}.js`,
153153
libraryTarget: 'commonjs2',
154154
},
155-
devtool: 'source-map',
155+
devtool: process.env.NEXT_SERVER_EVAL_SOURCE_MAPS
156+
? 'eval-source-map'
157+
: 'source-map',
156158
optimization: {
157159
moduleIds: 'named',
158160
minimize: true,

0 commit comments

Comments
 (0)