You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix: keep an empty string in sourcesContent - #314
streamChunksOfSourceMap read each entry as (sourcesContent && sourcesContent[i]) || undefined, so an empty file's content "" became "no content". A missing entry tells a consumer to fetch the file itself, so the map loses information. Found while moving minimizer-webpack-plugin onto SourceMapSource for chaining maps; its test for exactly this case failed.
Yes, test/SourceMapSource.js ("should keep an empty source content"): map() and sourceAndMap() with and without columns, and through an inner source map. It fails without the fix.
Does this PR introduce a breaking change?
No.
If relevant, what needs to be documented once your changes are merged or what have you already documented?
n/a
Use of AI
Written with Claude Code from my requirements; I reviewed the fix and the test.
All four source-map streaming paths now pass sourcesContent values to onSource only when they are strings. Tests verify that empty strings remain in map() and sourceAndMap() results, including when composing source maps. A changeset declares a patch release and describes retaining empty strings in sourcesContent.
Priority: Normal
Merge Risk: Low · up to 26747
The fix is mergeable with a bounded test-coverage follow-up: add a combined-map assertion with columns disabled to protect empty source content in that mode.
Pre-merge checks: 5
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title "fix: keep an empty string in sourcesContent" matches the main change. The PR stops streamChunksOfSourceMap from treating an empty string in sourcesContent as missing. The diff changes lib/h…
Docstring Coverage
No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title "fix: keep an empty string in sourcesContent" matches the main change. The PR stops streamChunksOfSourceMap from treating an empty string in sourcesContent as missing. The diff changes lib/helpers/streamChunksOfSourceMap.js so that onSource receives sourcesContent[i] only when it is a string. It also adds a changeset and a regression test in test/SourceMapSource.js that covers map(), sourceAndMap(), and inner source map composition. The title is specific, concise, and free of file lists or vague terms.
Full details: Docstring Coverage
Explanation
No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 2 files. (1 skipped: 1 unsupported.)
Finishing Touches
📝 Generate docstrings
Commit to this branch
Create a new PR
🧪 Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Warning
Some tools did not complete. Review the errors below.
ESLint
If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.
test/SourceMapSource.js
Oops! Something went wrong! :(
ESLint: 9.39.5
Error: Error while loading rule 'jest/no-deprecated-functions': Unable to detect Jest version - please ensure jest package is installed, or otherwise set version explicitly
Occurred while linting /test/SourceMapSource.js
at detectJestVersion (/.eslint-tmp/node_modules/eslint-plugin-jest/lib/rules/utils/detectJestVersion.js:22:9)
at create (/.eslint-tmp/node_modules/eslint-plugin-jest/lib/rules/no-deprecated-functions.js:31:107)
at Object.create (/.eslint-tmp/node_modules/@typescript-eslint/utils/dist/eslint-utils/RuleCreator.js:39:20)
at createRuleListeners (/.eslint-tmp/node_modules/eslint/lib/linter/linter.js:1019:15)
at /.eslint-tmp/node_modules/eslint/lib/linter/linter.js:1151:7
at Array.forEach ()
at runRules (/.eslint-tmp/node_modules/eslint/lib/linter/linter.js:1085:31)
at #flatVerifyWithoutProcessors (/.eslint-tmp/node_modules/eslint/lib/linter/linter.js:2115:4)
at Linter._verifyWithFlatConfigArrayAndWithoutProcessors (/.eslint-tmp/node_modules/eslint/lib/linter/linter.js:2203:43)
at Linter._verifyWithFlatConfigArray (/.eslint-tmp/node_modules/eslint/lib/linter/linter.js:2306:15)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Cover the combined columns: false path for empty sourcesContent.
The new assertion calls combined.map() with no options. getMap spreads those options and does not add columns, so the combined branch evaluates columns as true and uses the column-aware helpers. The sourcesContent expressions in streamChunksOfSourceMapLinesFull and streamChunksOfSourceMapLinesFinal run only when columns is false. A regression in those expressions that drops "" would not fail this test.
The file's other { columns: false } cases do not cover this path. The non-combined loop uses a source without an inner map, and map() returns that map directly. No other fixture in this file uses an empty sourcesContent entry.
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: e5436731-8821-4084-b0b2-a0eafbf868bc
Commits
Reviewing files that changed from the base of the PR and between 99067d0 and 267476f.
Files selected for processing: 3
.changeset/keep-empty-source-content.md
lib/helpers/streamChunksOfSourceMap.js
test/SourceMapSource.js
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.
Merging this PR will degrade performance by 19.62%
2 warnings
⚠️1 benchmark is dominated by system calls
System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.
Some benchmarks with significant performance changes were compared across different runner types, so the changes might not come from the code. Run base and head on the same runner type, or use CodSpeed Macro Runners for more stable results.
CodSpeed Performance Analysis is red, but the regressions aren't from this PR:
The regressed benchmarks are constructors and accessors this diff doesn't touch (new RawSource(string), new OriginalSource(buffer), new PrefixSource(...), raw-source: map()). The only change is a typeof check run once per source in streamChunksOfSourceMap.
CodSpeed reports the base and head ran on different environments: CPU AMD EPYC 7763 → Intel Xeon, Node 24.21.0 → 24.22.1.
Control: feat: add util.sourceMap.originalPositionFor #313 adds only a new file nothing on these paths loads, and against the same base it shows the same pattern (23 regressions, cached-source memory: warm sourceAndMap() 8 B → 992 B, new OriginalSource(buffer) −43%).
No fix to port; it needs the regressions acknowledged on CodSpeed or a base run on the same runner type.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
streamChunksOfSourceMapread each entry as(sourcesContent && sourcesContent[i]) || undefined, so an empty file's content""became "no content". A missing entry tells a consumer to fetch the file itself, so the map loses information. Found while movingminimizer-webpack-pluginontoSourceMapSourcefor chaining maps; its test for exactly this case failed.nullentries still read as missing.What kind of change does this PR introduce?
fix
Did you add tests for your changes?
Yes,
test/SourceMapSource.js("should keep an empty source content"):map()andsourceAndMap()with and without columns, and through an inner source map. It fails without the fix.Does this PR introduce a breaking change?
No.
If relevant, what needs to be documented once your changes are merged or what have you already documented?
n/a
Use of AI
Written with Claude Code from my requirements; I reviewed the fix and the test.
Generated by Claude Code
Summary by CodeRabbit