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:
@@ -8,6 +8,19 @@
|
||||
*/
|
||||
type SourceMapRecord = Readonly<Record<string, unknown>>;
|
||||
|
||||
/**
|
||||
* Return the JSON parsing view of retained source-map text. ECMA-426 permits
|
||||
* HTTP responses to start with `)]}'`; the first line is transport framing.
|
||||
* Keep the original text for artifact identity and Evidence provenance.
|
||||
* 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);
|
||||
};
|
||||
|
||||
const isRecord = (value: unknown): value is SourceMapRecord =>
|
||||
typeof value === "object" && value !== null && !Array.isArray(value);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user