mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 22:17:42 +00:00
LibJS: Allow exporting any imported bindings
This commit is contained in:
parent
462c6df24b
commit
faf1430ce4
3 changed files with 19 additions and 1 deletions
|
@ -565,8 +565,15 @@ void Parser::parse_module(Program& program)
|
||||||
if (name == exported_name)
|
if (name == exported_name)
|
||||||
found = true;
|
found = true;
|
||||||
});
|
});
|
||||||
|
for (auto& import : program.imports()) {
|
||||||
|
if (import.has_bound_name(exported_name)) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!found)
|
if (!found)
|
||||||
syntax_error(String::formatted("'{}' is not declared", exported_name));
|
syntax_error(String::formatted("'{}' in export is not declared", exported_name), export_statement.source_range().start);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -190,6 +190,10 @@ describe("in- and exports", () => {
|
||||||
test("can have multiple star imports even from the same file", () => {
|
test("can have multiple star imports even from the same file", () => {
|
||||||
expectModulePassed("./multiple-star-imports.mjs");
|
expectModulePassed("./multiple-star-imports.mjs");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("can export namespace via binding", () => {
|
||||||
|
expectModulePassed("./re-export-namespace-via-binding.mjs");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("loops", () => {
|
describe("loops", () => {
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
import * as namespace from "./default-and-star-export.mjs";
|
||||||
|
import { "*" as fromStar } from "./default-and-star-export.mjs";
|
||||||
|
export { namespace };
|
||||||
|
|
||||||
|
import { namespace as nm } from "./re-export-namespace-via-binding.mjs";
|
||||||
|
|
||||||
|
export const passed = nm === namespace && fromStar === namespace["*"];
|
Loading…
Add table
Add a link
Reference in a new issue