mirror of
https://github.com/morluto/rea
synced 2026-10-26 14:25:49 -04:00
fix: select Node legacy package entry fields for import and require (#1035)
fix(javascript): use Node legacy package entry fields Signed-off-by: Rudy Celekli <47457359+rudycelekli@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
68b9fa489b
commit
170600541b
@@ -461,10 +461,12 @@ const packageEntry = (
|
||||
? { ...exported, source: "exports" }
|
||||
: exported;
|
||||
}
|
||||
const preferred =
|
||||
moduleKind === "import"
|
||||
? [Reflect.get(value, "module"), Reflect.get(value, "main")]
|
||||
: [Reflect.get(value, "main"), Reflect.get(value, "module")];
|
||||
// Node imports and requires ignore the bundler-only module field. Keep
|
||||
// that fallback for callers without an explicit module-loading kind.
|
||||
const preferred = [
|
||||
Reflect.get(value, "main"),
|
||||
...(moduleKind === undefined ? [Reflect.get(value, "module")] : []),
|
||||
];
|
||||
const entry = preferred.find((candidate) => candidate !== undefined);
|
||||
if (entry === undefined) return { status: "missing" };
|
||||
const legacy = packagePathValue(entry);
|
||||
|
||||
Reference in New Issue
Block a user