1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 19:58:11 +00:00

LibJS+LibWeb: Another round of bringing module loading closer to spec

In particular, this patch focuses on:
- Updating the old "import assertions" to the new "import attributes"
- Allowing realms as module import referrer
This commit is contained in:
Andreas Kling 2023-12-02 16:20:01 +01:00
parent 82977ab44b
commit 07f567cd9f
14 changed files with 244 additions and 178 deletions

View file

@ -18,13 +18,14 @@ struct ModuleWithSpecifier {
NonnullGCPtr<Module> module; // [[Module]]
};
// 2.9 ModuleRequest Records, https://tc39.es/proposal-import-assertions/#sec-modulerequest-record
struct ModuleRequest {
struct Assertion {
DeprecatedString key;
DeprecatedString value;
};
// https://tc39.es/proposal-import-attributes/#importattribute-record
struct ImportAttribute {
DeprecatedString key;
DeprecatedString value;
};
// https://tc39.es/proposal-import-attributes/#modulerequest-record
struct ModuleRequest {
ModuleRequest() = default;
explicit ModuleRequest(DeprecatedFlyString specifier)
@ -32,15 +33,15 @@ struct ModuleRequest {
{
}
ModuleRequest(DeprecatedFlyString module_specifier, Vector<Assertion> assertions);
ModuleRequest(DeprecatedFlyString specifier, Vector<ImportAttribute> attributes);
void add_assertion(DeprecatedString key, DeprecatedString value)
void add_attribute(DeprecatedString key, DeprecatedString value)
{
assertions.empend(move(key), move(value));
attributes.empend(move(key), move(value));
}
DeprecatedFlyString module_specifier; // [[Specifier]]
Vector<Assertion> assertions; // [[Assertions]]
Vector<ImportAttribute> attributes; // [[Attributes]]
};
}