lib: skip source maps in node_modules by default #67627
Review requested:
Approved these changes.
Codecov Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 90.54%. Comparing base (
3cac7b9) to head (ab46878).:warning: Report is 12 commits behind head on main.
<details><summary>Additional details and impacted files</summary>
@@ 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%) | :arrow_down: |
... and 42 files with indirect coverage changes
</details>
<details><summary> :rocket: New features to boost your workflow: </summary>
</details>
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.
Given there's an option to unskip, it's probably a good idea add "by default"
description: Source maps in `node_modules` and generated code are skipped by default.
@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.
anonrig
legendecas
This updates the flag
--enable-source-maps, skippingnode_modulesand generated code by default.If source map support for
node_modulesand generated code are needed, it can be enabled withmodule.setSourceMapsSupport(). This could improve general app development source map performance.