Skip to content

module: Set dynamic import callback#15713

Closed
hybrist wants to merge 1 commit intonodejs:masterfrom
hybrist:jk-dynamic-import
Closed

module: Set dynamic import callback#15713
hybrist wants to merge 1 commit intonodejs:masterfrom
hybrist:jk-dynamic-import

Conversation

@hybrist
Copy link
Copy Markdown
Contributor

@hybrist hybrist commented Oct 1, 2017

This is an initial implementation to support dynamic import in
both scripts and modules. It's off by default since support for
dynamic import is still flagged in V8. Without setting the V8 flag,
this code won't be executed.

Because of missing support in the V8 APIs, we can't support
importing into the proper context yet. Without further changes this
might allow code to break out of the context it's running in.

/cc @bmeck

TODO

  • Add test case to ensure import from "random contexts" is ignored
  • Clean error handling when calling import() before the callback is set up (can't think of a scenario where this might happen)
  • Cleanup code for handling import from CommonJS scripts
  • Potentially add explicit error handling for failing import handler call (just preventing a crash for now)
  • Ensure behavior matches browsers where appropriate (e.g. eval & friends)
Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)

module

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

Labels

esm Issues and PRs related to the ECMAScript Modules implementation. lib / src Issues and PRs related to general changes in the lib or src directory. module Issues and PRs related to the module subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.