fix(javascript): select JSON and addon loaders by exact suffix (#7821)

Node's CommonJS loader matches registered extensions case-sensitively, so
require("./data.JSON") and require("./addon.NODE") run as JavaScript.
Derive target_json_status and the native loads relation from the exact
loader suffix instead of the inventory's case-folded file kind.

Fixes #7623
This commit is contained in:
RRFZ authored and GitHub committed 2026-10-29 13:43:55 +08:00
1 parent 4fbce5c122
commit fca331804a
4 files changed
+70 -6

No files matched your search

@@ -8,6 +8,12 @@ export const isJsonModuleTarget = (
): boolean =>
path.endsWith(".json") && (kind === "json" || kind === "package-json");
/** Native-addon dispatch likewise needs the exact `.node` loader suffix. */
export const isNativeAddonModuleTarget = (
path: string,
kind: JavaScriptArtifactFileKind | undefined,
): boolean => path.endsWith(".node") && kind === "native-addon";
/** Loader evidence retained for a source-level module reference. */
export type JavaScriptModuleResolutionMode =
| "import"