LibJS+LibWeb: Add C++ compile_parsed_module wrapper

Add compile_parsed_module() to RustIntegration, which takes a
RustParsedProgram and a SourceCode (from parse_program with
ProgramType::Module) and compiles it on the main thread with GC
interaction.

Rewrite compile_module() to use the new split functions internally.

Add SourceTextModule::parse_from_pre_parsed() and
JavaScriptModuleScript::create_from_pre_parsed() to allow creating
module scripts from a pre-parsed RustParsedProgram.

This prepares the infrastructure for off-thread module parsing.
This commit is contained in:
Andreas Kling
2026-02-27 23:44:44 +01:00
committed by Andreas Kling
parent 7d45e897c4
commit 3f4d3d6108
Notes: github-actions[bot] 2026-03-06 12:07:29 +00:00
6 changed files with 132 additions and 59 deletions

View File

@@ -10,6 +10,8 @@
#include <LibWeb/Export.h>
#include <LibWeb/HTML/Scripting/Script.h>
struct RustParsedProgram;
namespace Web::HTML {
// https://html.spec.whatwg.org/multipage/webappapis.html#module-script
@@ -34,6 +36,7 @@ public:
virtual ~JavaScriptModuleScript() override;
static WebIDL::ExceptionOr<GC::Ptr<JavaScriptModuleScript>> create(ByteString const& filename, StringView source, JS::Realm&, URL::URL base_url);
static WebIDL::ExceptionOr<GC::Ptr<JavaScriptModuleScript>> create_from_pre_parsed(ByteString const& filename, StringView source, JS::Realm&, URL::URL base_url, RustParsedProgram* parsed);
enum class PreventErrorReporting {
Yes,