mirror of
https://github.com/morluto/rea.git
synced 2026-12-06 17:23:37 +08:00
refactor(reference): reuse the import UTF-8 decoder (#17356)
This commit is contained in:
@@ -35,7 +35,7 @@ import {
|
||||
isTSModuleDeclaration,
|
||||
} from "@babel/types";
|
||||
import type { HistoricalSourceGraph } from "./referenceSourceGraph.js";
|
||||
import { decodeStrictUtf8 } from "./strictUtf8.js";
|
||||
import { decodeUtf8PreservingBomOrNull } from "./strictUtf8.js";
|
||||
|
||||
interface ReferenceSourceImportRelationship extends Readonly<
|
||||
Pick<
|
||||
@@ -305,11 +305,9 @@ export const parseReferenceSourceImports = (
|
||||
if (language !== null && !PARSEABLE_REFERENCE_SOURCE_LANGUAGES.has(language))
|
||||
return { relationships: [], parse_failures: [], limitations: [] };
|
||||
|
||||
let source: string;
|
||||
try {
|
||||
// The shared parser owns loader-specific BOM/hashbang preprocessing.
|
||||
source = decodeStrictUtf8(bytes, "preserve");
|
||||
} catch {
|
||||
// The shared parser owns loader-specific BOM/hashbang preprocessing.
|
||||
const source = decodeUtf8PreservingBomOrNull(bytes);
|
||||
if (source === null) {
|
||||
return {
|
||||
relationships: [],
|
||||
parse_failures: [
|
||||
|
||||
Reference in New Issue
Block a user