Skip to content

lib: use Object.freeze to avoid defensive cloning in SourceMap#62830

Open
watilde wants to merge 2 commits intonodejs:mainfrom
watilde:fixes-memory-sourcemap
Open

lib: use Object.freeze to avoid defensive cloning in SourceMap#62830
watilde wants to merge 2 commits intonodejs:mainfrom
watilde:fixes-memory-sourcemap

Conversation

@watilde
Copy link
Copy Markdown
Member

@watilde watilde commented Apr 19, 2026

No description provided.

@nodejs-github-bot nodejs-github-bot added the needs-ci PRs that need a full CI run. label Apr 19, 2026
@watilde watilde force-pushed the fixes-memory-sourcemap branch from 3b8cc82 to 73ffd8a Compare April 19, 2026 10:40
@watilde watilde changed the title perf: use Object.freeze to avoid defensive cloning in SourceMap lib: use Object.freeze to avoid defensive cloning in SourceMap Apr 19, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.60%. Comparing base (58a8e1d) to head (ab627d7).
⚠️ Report is 30 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #62830      +/-   ##
==========================================
- Coverage   89.69%   89.60%   -0.09%     
==========================================
  Files         706      706              
  Lines      218222   219163     +941     
  Branches    41768    41988     +220     
==========================================
+ Hits       195731   196382     +651     
- Misses      14411    14680     +269     
- Partials     8080     8101      +21     
Files with missing lines Coverage Δ
lib/internal/source_map/source_map.js 99.48% <100.00%> (+0.25%) ⬆️

... and 55 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.

@legendecas legendecas added 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. labels Apr 20, 2026
Copy link
Copy Markdown
Member

@legendecas legendecas left a comment

Choose a reason for hiding this comment

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

Would you mind adding a note on https://github.com/nodejs/node/blob/main/doc/api/module.md#sourcemappayload that the returned payload is frozen? Thanks!

Copy link
Copy Markdown
Member

@legendecas legendecas left a comment

Choose a reason for hiding this comment

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

Would you mind fixing the linter complaints? Thanks

Comment thread doc/api/module.md
generated code.

#### `sourceMap.payload`

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.

Worth to add a change section:

Suggested change
<!-- YAML
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/62830
description: The object is frozen.

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. 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.

3 participants