Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support ES2015 modules #945

Open
p-bakker opened this issue Jun 23, 2021 · 4 comments
Open

Support ES2015 modules #945

p-bakker opened this issue Jun 23, 2021 · 4 comments
Labels
Ecma Incompatibility Issues about Rhino being incompatible with the EcmaScript spec feature Issues considered a new feature
Milestone

Comments

@p-bakker
Copy link
Collaborator

p-bakker commented Jun 23, 2021

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:

  • Should module support be enabled by default?
    In cases where Rhino is integrated, maybe all of a sudden having the ability to import modules after upgrading Rhino is a security concern?
  • Where to load modules from?
    • Should probably be customizable (disk/url/jar/database/etc)
    • What's the base for relative paths?
    • Should we have a default loading mechanism and if so which one?
    • Maybe in the Shell we should support loading from disk by default?
  • Are we affected by any of the challenges NodeJS had regarding supporting both CommonJS modules and ES Modules? Rhino supports CommonJS modules (as an opt-in)
@gausie
Copy link
Contributor

gausie commented Jun 23, 2021

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

@p-bakker
Copy link
Collaborator Author

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 p-bakker added this to the ES2015 milestone Jun 29, 2021
@p-bakker p-bakker added the feature Issues considered a new feature label Oct 14, 2021
@p-bakker p-bakker added the Ecma Incompatibility Issues about Rhino being incompatible with the EcmaScript spec label Jul 30, 2024
@p-bakker
Copy link
Collaborator Author

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
Copy link
Collaborator Author

p-bakker commented Sep 1, 2024

@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? 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ecma Incompatibility Issues about Rhino being incompatible with the EcmaScript spec feature Issues considered a new feature
Projects
None yet
Development

No branches or pull requests

2 participants