fix(javascript): preserve package and source-map boundary identity (#1939)

* fix(javascript): preserve bare package specifier suffixes

* fix(javascript): resolve ESM package self references

* fix(javascript): recover retained prefixed source maps

* test(javascript): cover suffixed ESM self references

* fix(javascript): retain legacy ESM package suffix behavior

* fix(javascript): reject legacy ESM directory and extension fallback

* refactor(javascript): consolidate package resolution and workflow coverage

* fix(javascript): report exact ESM package subpath misses

* fix(javascript): compare parsed names for ESM self references

* refactor(javascript): parse bare package requests once

* fix(javascript): derive ESM dependency lookup from package URLs

---------

Co-authored-by: hhang <169027046+xu91102@users.noreply.github.com>
This commit is contained in:
morluto
2026-10-12 04:09:17 +08:00
committed by GitHub
parent 85c1d2587a
commit 14935e4d47
13 changed files with 860 additions and 157 deletions
+1 -14
View File
@@ -1,6 +1,7 @@
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";
const leafSchema = z.object({
version: z.literal(3),
@@ -279,20 +280,6 @@ const inspectLeaf = (
return leaf;
};
/**
* Return the JSON view of source-map text without changing the source evidence.
* ECMA-426 §11.2.1 permits HTTP(S) responses to start with `)]}'`; the line
* through the first HTTP newline is transport framing, not map content. Local
* point tracing shares this parser and has historically accepted the same
* framing. https://tc39.es/ecma426/#sec-fetchsourcemap
*/
export const sourceMapJsonText = (text: string): string => {
const withoutBom = text.replace(/^\uFEFF/u, "");
if (!withoutBom.startsWith(")]}'")) return withoutBom;
const newline = withoutBom.search(/[\r\n]/u);
return newline === -1 ? "" : withoutBom.slice(newline);
};
/** Validate structure before allocation, retaining raw declarations and section boundaries. */
export const inspectSourceMap = (
text: string,