forked from sqreen/PyMiniRacer
-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Description
I'm planning to implement support for ES6/ES2015 style JavaScript Modules (commonly known as "ESModules" or "ECMAScript Modules"). The purpose of this issue is to track the progress / share with anyone else who may be working on the same thing or wants the feature/wants to test it.
Overall:
- Implement a standard V8 module callback that then reaches into the mini-racer Python module.
- Add some functions to mini-racer to be called to resolve modules.
- Implement a module resolver; in its simplest incarnation, this would just look for a .js (or .mjs) file in the current directory.
- More sophisticated module resolvers could be built and enabled.
- Module resolution will vary considerably from how a typical web browser works.
A simple implementation would be able to do this:
sample_module.mjs:
export function my_func() { return 123; }use_module.py:
from py_mini_racer import MiniRacer
ctx = MiniRacer()
ctx.import_module('my_func', './sample_modules.mjs')
print(f"Should be 123: {ctx.call("my_func")}")bollwyvl
Metadata
Metadata
Assignees
Labels
No labels