fix(javascript): preserve map boundaries and loader provenance

Share embedded-map version admission and derive indexed overlap from represented mappings. Carry createRequire filename bases through worker facts and graph identity. Select factory export bindings at each bundler owner.

Validated accepted and malformed source maps through real CLI and stdio MCP codec workflows; verified loader and esbuild graph output against Node runtime controls. Rebased consumer checks passed.

Fixes #6803

Fixes #6614

Fixes #6798

Fixes #6797
This commit is contained in:
morluto committed 2026-10-24 01:00:14 +08:00
1 parent d78892eb4b
commit ccba355fa9
15 files changed
+373 -32

No files matched your search

+6 -8
View File
@@ -147,10 +147,10 @@ const addSections = ({
for (const [index, section] of sections.entries()) {
if ((index & 255) === 0) options.check?.();
const previous = sections[index - 1];
if (previous !== undefined && compare(section.offset, previous.offset) <= 0)
if (previous !== undefined && compare(section.offset, previous.offset) < 0)
throw new SourceMapFormatFailure(
"format",
"Indexed section offsets must be strictly increasing.",
"Indexed section offsets must be in nondecreasing order.",
);
const classification = classifySourceMapSection(section);
if (classification.kind === "external")
@@ -159,7 +159,10 @@ const addSections = ({
`External source-map section URL is not fetched: ${classification.url}`,
);
if (classification.kind === "invalid")
throw new SourceMapFormatFailure("format", classification.reason);
throw new SourceMapFormatFailure(
"format",
`${classification.reason} Section path: ${JSON.stringify([...node.path, index])}.`,
);
embeddedMaps.push(classification.map);
}
for (let index = sections.length - 1; index >= 0; index -= 1) {
@@ -181,11 +184,6 @@ const addSections = ({
? nextOffset
: node.stop;
const offset = addOffset(node.offset, section.offset);
if (node.stop !== null && compare(offset, node.stop) >= 0)
throw new SourceMapFormatFailure(
"format",
"Nested source-map section overlaps its enclosing boundary.",
);
pending.push({
value: map,
path: [...node.path, index],
@@ -63,7 +63,8 @@ it("uses the same conservative section classification for URL-plus-map and malfo
expect(malformed).toThrow(
expect.objectContaining({
reason: "format",
message: "External source-map section URL must be a string.",
message:
"External source-map section URL must be a string. Section path: [0].",
}),
);
});