Skip to content

module: Set dynamic import callback

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

Merge request reports

Loading