mirror of
https://github.com/morluto/rea.git
synced 2026-10-31 11:56:12 +00:00
fix(javascript): preserve lexical binding and default export capture semantics
Resolve CommonJS wrapper bindings from the parser-owned source type. Capture default identifier export values at the export statement while preserving live named bindings. Refs: #3261, #3297 Co-authored-by: hhang <169027046+xu91102@users.noreply.github.com>
This commit is contained in:
1 parent
322506d0c0
commit
dae1e55381
6 files changed
+111
-16
No files matched your search
@@ -62,6 +62,23 @@ describe("TypeScript import-equals links", () => {
|
||||
});
|
||||
|
||||
describe("CommonJS wrapper parameter redeclarations", () => {
|
||||
it("does not infer a CommonJS wrapper from resolution mode in an explicit module", () => {
|
||||
const path = "app/main.mjs";
|
||||
const parsed = parseJavaScriptSource(
|
||||
'var require; require("./dependency.cjs");',
|
||||
path,
|
||||
);
|
||||
expect(parsed).not.toBeNull();
|
||||
expect(parsed?.program.sourceType).toBe("module");
|
||||
const ir = analyzeParsedJavaScriptSemantics(
|
||||
parsed!,
|
||||
moduleResolutionModeForJavaScriptReference(path, "static-import"),
|
||||
);
|
||||
expect(ir.moduleLinks).not.toContainEqual(
|
||||
expect.objectContaining({ specifier: "./dependency.cjs" }),
|
||||
);
|
||||
});
|
||||
|
||||
it("retains ambient exports and require through uninitialized top-level vars", () => {
|
||||
const path = "app/main.cjs";
|
||||
const parsed = parseJavaScriptSource(
|
||||
|
||||
Reference in new issue
Block a user