mirror of
https://github.com/morluto/rea
synced 2026-10-28 15:07:26 -04:00
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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user