Skip to content

lib: skip source maps in node_modules by default - #67627

Open
legendecas wants to merge 1 commit into
nodejs:mainfrom
legendecas:source-maps-nodemodules
Open

legendecas wants to merge 1 commit into
nodejs:mainfrom
legendecas:source-maps-nodemodules

Conversation

@legendecas

Copy link
Copy Markdown
Member

This updates the flag --enable-source-maps, skipping node_modules and generated code by default.

If source map support for node_modules and generated code are needed, it can be enabled with module.setSourceMapsSupport(). This could improve general app development source map performance.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/loaders

@legendecas legendecas added the semver-major PRs that contain breaking changes and should be released in the next major version. label Nov 19, 2026
@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. process Issues and PRs related to the process subsystem. source maps Issues and PRs related to source map support. labels Nov 19, 2026
@legendecas
legendecas force-pushed the source-maps-nodemodules branch 2 times, most recently from 7312cac to 7bd74b0 Compare November 19, 2026 22:20
@legendecas legendecas added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Nov 19, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Nov 19, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@codecov

codecov Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.54%. Comparing base (3cac7b9) to head (ab46878).
⚠️ Report is 12 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #67627      +/-   ##
==========================================
- Coverage   90.55%   90.54%   -0.01%     
==========================================
  Files         801      803       +2     
  Lines      284215   285030     +815     
  Branches    54883    55002     +119     
==========================================
+ Hits       257358   258091     +733     
- Misses      17014    17095      +81     
- Partials     9843     9844       +1     
Files with missing lines Coverage Δ
lib/internal/process/pre_execution.js 96.24% <100.00%> (-0.02%) ⬇️

... and 42 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Frameworks like Next.js need source maps support to support a good debugging experience. I think if we want to do this, we need to add a CLI flag.

Also, this might be semver-major.

Comment thread doc/api/cli.md Resolved
@legendecas
legendecas force-pushed the source-maps-nodemodules branch from 7bd74b0 to cf691b4 Compare November 23, 2026 19:15
@legendecas

Copy link
Copy Markdown
Member Author

@mcollina Next.js puts their compiled app code in .next/server/..., which is outside node_modules, so the default --enable-source-maps still enables source map for app codes even with this change.

This PR skips source map in node_modules, like Next.js's own runtime in node_modules/next/dist/compiled/..... The effect is expected to be limited, and frameworks like Next.js already hides any frame whose path includes node_modules (patch-error-inspect.ts#L228-L232).

This PR is intended to avoid source map overhead on node_modules, which frameworks and app owners usually don't care about (as shown in next's case).

Dug a bit, I think your point reminded me that some frameworks do depend on the generated-code bit. E.g. next.js has a non-default mode next dev --webpack that depends on eval-source-map, which relies on the generated-code source maps.

I have reverted the --enable-source-maps to enable source maps on generated code still. And this PR is only intended to skip source maps in node_modules.

Signed-off-by: Chengzhong Wu <cwu631@bloomberg.net>
@legendecas
legendecas force-pushed the source-maps-nodemodules branch from cf691b4 to ab46878 Compare November 23, 2026 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ci PRs that need a full CI run. process Issues and PRs related to the process subsystem. semver-major PRs that contain breaking changes and should be released in the next major version. source maps Issues and PRs related to source map support.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants