-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LibWeb+LibJS: Implement support for module scripts #15275
LibWeb+LibJS: Implement support for module scripts #15275
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just posting one comment to make sure I don't forget about it
Also for reference this PR uses/implements inspired by: whatwg/html#8264 And potentially https://github.com/nicolo-ribaudo/modules-import-hooks-refactor |
83be47b
to
1e8a758
Compare
1e8a758
to
0244a5b
Compare
I'll clean up more of the factoring and commit history in a bit. Currently this is mostly blocked on HostResolveImportedModule crashing because the current realm doesn't have [[HostDefined]] set (we need current settings object) and I don't know what we are missing to properly set [[HostDefined]] |
c58dee8
to
2eb7597
Compare
As of the commits I just pushed https://nwex.de/xhr.html started working :^) |
74240ab
to
b788946
Compare
Oh I wanted to have a proper solution to the realm execution context issue before marking this as ready. I'll look into that in a bit |
9057031
to
f1eb2db
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some initial comments.
I left a couple of comments about errors and only later saw we do crash on those. So since this is kind of an initial attempt we could ignore them for now.
I can/will take a deeper look if you feel it's ready
My main focus for this first cut was my own website but I can make more code paths work if you have a test case |
a151e19
to
6b38de2
Compare
Yeah I didn't notice the VERIFYs/TODOs you hit later on in the parse fail case. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once again just want to say great work!
Not all cases are covered but as a first step this feel good enough for me.
Certainly with the rewrite of the module spec (once from whatwg and another incoming from ecma) this will have to be looked at later as well.
Previously we would simply check the an input string against a list of mime type essences, ignoring that the input might not be a valid mime type or contain parameters. This patch moves the helpers into the MimeSniff namespace and properly parses an input string before comparing the essence.
This patch adds the module type allowed steps given a module type string and an environment settings object.
This patch adds the [[HostDefined]] field defined in https://tc39.es/ecma262/#table-module-record-fields to module records. Co-authored-by: davidot <[email protected]>
This patch adds support for all child classes of Web::HTML::Script to be used in the [[HostDefined]] field of JS::Modules and JS::Scripts.
This patch adds the ModuleMap class used to keep track of the type and url of a module as well as the fetching state associated. Each environment settings object now also has a module map.
This patchs adds the Web::HTML::Script subclass ModuleScript and JavaScriptModuleScript as a type of ModuleScript as well as various algorithms related to JavaScript module scripts. Co-authored-by: davidot <[email protected]>
This patch adds various algorithms required to fetch and link module scripts. Some parts such as actually creating a request and error handling are not implemented or use temporary non spec compliant code to get us further. Co-authored-by: davidot <[email protected]>
This patch adds support for the HostGetSupportedImportAssertions and HostResolveImportedModule host hooks. Co-authored-by: davidot <[email protected]>
This patch adds support for script elements with the type attribute set to "module". As a first cut the changes are mainly focused around inline scripts. Co-authored-by: davidot <[email protected]>
This patch adds a non standard step pushing the realm execution context of fetching client's settings object onto the execution context stack before linking a module script. Without the realm execution context there is no current settings object, leading to a crash in HostResolveImportedModule.
6b38de2
to
f8d7c33
Compare
This pull request is work towards getting websites using
<script type="module">
to work properly