Skip to content

fix(consumer): preserve empty indexed source content - #547

Open
Hanabi9248 wants to merge 1 commit into
mozilla:masterfrom
Hanabi9248:codex/indexed-empty-source-content-oct25
Open

Hanabi9248 wants to merge 1 commit into
mozilla:masterfrom
Hanabi9248:codex/indexed-empty-source-content-oct25

Conversation

@Hanabi9248

Copy link
Copy Markdown

Fixes #420.

An indexed source map containing sourcesContent: ["a\nb\nc\n", ""] treats the second source as absent: sourceContentFor() discards the valid empty string and either throws or returns null. SourceMapGenerator.fromSourceMap() consequently throws instead of preserving the empty file.

Accept content when it is non-null rather than truthy in IndexedSourceMapConsumer.sourceContentFor. Keep searching sections for null/undefined and retain the existing unknown-source exception/nullOnMissing behavior. No generator or missing-content policy changes are needed.

Validation on exact master 8c668f3dd3916e96d06131dec97c78a3e62bd0f3, Node.js v24.19.0:

  • Eight new methods use real Basic/Indexed SourceMapConsumer construction, real SourceMapGenerator conversion and finally/destroy cleanup. Original source: five failures, three controls pass. Proposed source: 8/8 pass. Cases include the original issue input, later-section lookup, nested indexed maps, empty versus null content, nonempty content and missing-source behavior.
  • Existing consumer suite: 64/64 pass. Existing generator suite: 29/29 pass. These are separate suites, not a combined rerun.
  • Official support sources and the actual WASM blob 7fc7d86ea2eeaa49762fc0dbbd1c3086c0447ee3 are bound to this base; no fake consumers, private-field replacement or WASM stubs.
  • Validation ran serially under one CPU, 768 MiB for the whole job, 16 processes, private TMP and BLAS threads set to one; peak job memory across these runs was 36,708,352 bytes. Production-source whitespace check passes.

Browser integration, other Node.js versions and the full repository suite were not run; no dependencies or toolchains were installed. The nullOnMissing policy changes proposed in #391 are outside this fix.

AI assistance was used for investigation, implementation and validation.

Treat empty source text as present while preserving missing-source behavior.
Cover real indexed consumers and generator conversion, including nested sections.

Signed-off-by: Hanabi <317387557+Hanabi9248@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error creating a SourceMapGenerator from a SourceMapConsumer of an index map (part 2)

1 participant