Skip to content

feat: add ES module support for V8 JavaScript runtime#41

Open
dbhurley wants to merge 1 commit intomasterfrom
feat/es-module-support
Open

feat: add ES module support for V8 JavaScript runtime#41
dbhurley wants to merge 1 commit intomasterfrom
feat/es-module-support

Conversation

@dbhurley
Copy link
Copy Markdown
Member

Summary

  • Detect type="module" scripts during HTML extraction (previously skipped)
  • Add is_module flag to ScriptBlock and ResolvedScript types
  • Implement execute_module() using V8's module compilation API with proper ScriptOrigin
  • Update execute_page_scripts() to route modules through the module compiler

Why

Many modern sites ship ES modules (React, Vue, Vite-built apps). Without this, Plasmate's JS execution would fail to parse import/export syntax, causing silent script failures on module-heavy pages.

Test plan

  • test_execute_module_basic - verifies basic module compilation
  • test_execute_module_export_syntax - verifies export declarations compile
  • test_page_scripts_with_modules - verifies mixed classic + module execution
  • cargo test js:: - all 96 JS tests pass
  • cargo test - full suite passes

Notes

  • Import resolution currently returns None (dynamic imports not yet supported)
  • Self-contained modules work correctly
  • Classic script var bindings remain accessible across scripts

🤖 Generated with Claude Code

- 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>
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 21, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
plasmate-app Ready Ready Preview, Comment Apr 21, 2026 0:36am

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant