mozilla / rhino

Rhino is an open-source implementation of JavaScript written entirely in Java
https://rhino.github.io
Other
4.18k stars 851 forks source link

Support ES2015 modules #945

Open p-bakker opened 3 years ago

p-bakker commented 3 years ago

Big topic, see MDN Modules for some primer

Depends on Support ES5 this handling in strict mode, as all module code is to run in strict mode (and any other strict-mode anomalies we might have)

Some questions to be answered before setting out implementing this:

gausie commented 3 years ago

I'd like to be able to continue to specify a resolver as we do for the existing require implementation

p-bakker commented 3 years ago

I agree: where we use Rhino, I foresee us loading modules from a blob in the database or some other persistence store, so we need full control over how module paths are resolved

p-bakker commented 3 months ago

Additionally, we could support importing Java classes & packages through the ESM import statement: I think ESM allows for importing from 'modules' that aren't implemented in JavaScript

p-bakker commented 2 months ago

@szegedi as you authored the CommonJS implementation at one point in time and you seem to like fun tasks 😛, any chance you'd be interested in taking a stab at this one? 🙏