feat: add ES module support for V8 JavaScript runtime#41
Open
feat: add ES module support for V8 JavaScript runtime#41
Conversation
- Add is_module flag to ScriptBlock and ResolvedScript - Detect type="module" in script extraction (no longer skipped) - Implement execute_module() using V8's module compilation API - Update execute_page_scripts() to route modules vs classic scripts - Add tests for module compilation, exports, and mixed execution Modules are parsed with V8's module compiler and evaluated separately from classic scripts. Import resolution returns None (imports not yet supported) but self-contained modules work correctly. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
type="module"scripts during HTML extraction (previously skipped)is_moduleflag toScriptBlockandResolvedScripttypesexecute_module()using V8's module compilation API with properScriptOriginexecute_page_scripts()to route modules through the module compilerWhy
Many modern sites ship ES modules (React, Vue, Vite-built apps). Without this, Plasmate's JS execution would fail to parse
import/exportsyntax, causing silent script failures on module-heavy pages.Test plan
test_execute_module_basic- verifies basic module compilationtest_execute_module_export_syntax- verifies export declarations compiletest_page_scripts_with_modules- verifies mixed classic + module executioncargo test js::- all 96 JS tests passcargo test- full suite passesNotes
None(dynamic imports not yet supported)varbindings remain accessible across scripts🤖 Generated with Claude Code