Skip to content

Support for ES6/ES2015 ECMAScript Modules #82

@JoshRodd

Description

@JoshRodd

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")}")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions