mirror of
https://github.com/morluto/rea.git
synced 2026-10-28 10:25:42 +00:00
fix(reference): retain unknown package scope for JavaScript loaders
This commit is contained in:
1 parent
97e1b93f13
commit
c3e4c116d5
7 files changed
+53
-17
No files matched your search
@@ -400,3 +400,28 @@ it.each([
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
it("retains unknown historical .js loader scope until a package manifest establishes it", () => {
|
||||
const bytes = new TextEncoder().encode('require("./dep.cjs");');
|
||||
const relationships = (
|
||||
mode?: "module" | "commonjs" | "unspecified" | "unknown",
|
||||
) =>
|
||||
parseReferenceSourceImports("main.js", bytes, "JavaScript", mode)
|
||||
.relationships;
|
||||
expect(relationships()).toEqual([
|
||||
expect.objectContaining({
|
||||
to: "./dep.cjs",
|
||||
resolution: "unknown",
|
||||
parse_state: "partial",
|
||||
}),
|
||||
]);
|
||||
expect(relationships("module")).toEqual([]);
|
||||
for (const mode of ["commonjs", "unspecified"] as const)
|
||||
expect(relationships(mode)).toEqual([
|
||||
expect.objectContaining({
|
||||
to: "./dep.cjs",
|
||||
resolution: "internal",
|
||||
parse_state: "parsed",
|
||||
}),
|
||||
]);
|
||||
});
|
||||
Reference in new issue
Block a user