mirror of
https://github.com/morluto/rea.git
synced 2026-11-03 05:16:16 +00:00
fix(source-maps): keep sources when sourcesContent length differs (#2873)
ECMA-426 DecodeSourceMapSources reads a content slot only while its index is within sourcesContent, so a shorter array leaves trailing sources without content and a longer array adds no sources. Local application analysis and browser collection rejected any length mismatch and dropped every original from the map. The content helper now checks only entry types. Browser collection drops its separate check because the leaf schema already validates every supplied entry, and the raw records are still budgeted before parsing. Fixes #2821
This commit is contained in:
1 parent
855ed9689e
commit
3f80b75708
6 files changed
+114
-29
No files matched your search
@@ -1,6 +1,5 @@
|
||||
import { z } from "zod";
|
||||
import { WEB_SOURCE_MAP_LIMITS } from "../../domain/webSourceLocation.js";
|
||||
import { hasValidSourceMapContents } from "../../domain/sourceMapContents.js";
|
||||
import { sourceMapJsonText } from "../../domain/sourceMapEnvelope.js";
|
||||
import type { EncodedSourceMapXInput } from "@jridgewell/trace-mapping";
|
||||
|
||||
@@ -267,18 +266,6 @@ const inspectLeaf = (
|
||||
consumeRecords(budget, Array.isArray(rawNames) ? rawNames.length : 0);
|
||||
consumeRecords(budget, Array.isArray(rawContents) ? rawContents.length : 0);
|
||||
options.check?.();
|
||||
if (
|
||||
options.profile === "browser-collection" &&
|
||||
!hasValidSourceMapContents(
|
||||
Array.isArray(rawSources) ? rawSources.length : 0,
|
||||
rawContents,
|
||||
)
|
||||
)
|
||||
throw new SourceMapFormatFailure(
|
||||
"format",
|
||||
"Source-map sourcesContent must align with its source declarations.",
|
||||
);
|
||||
options.check?.();
|
||||
const leaf = leafSchema.parse(node.value);
|
||||
const layout = inspectMappingLayout(leaf.mappings, options.check);
|
||||
consumeRecords(budget, layout.segments + layout.lines);
|
||||
|
||||
Reference in new issue
Block a user