-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Proposal: Module Loader API #8327
Copy link
Copy link
Closed
Labels
clirelated to cli/ dirrelated to cli/ dirneeds discussionthis topic needs further discussion to determine what action to takethis topic needs further discussion to determine what action to takesuggestionsuggestions for new features (yet to be agreed)suggestions for new features (yet to be agreed)
Metadata
Metadata
Assignees
Labels
clirelated to cli/ dirrelated to cli/ dirneeds discussionthis topic needs further discussion to determine what action to takethis topic needs further discussion to determine what action to takesuggestionsuggestions for new features (yet to be agreed)suggestions for new features (yet to be agreed)
With ES Modules, it is effectively impossible to do "hot module reloading" of the modules, as ES Module specification is fairly strict that once the module is resolve and its two pass instantiation is done, that is the end of the road for the module and cannot be replaced.
When you are mocking/testing/etc. though, it is potentially valuable to make changes to a module and "reload" it via dynamic import. In Node.js, they have solved this problem with an experimental loader API. For an example of how this gets integrated to provide a mechanism for module replacements of imports that are still modules, quibble provides ESM support. It basically creates a unique specifier for every time the module is requested to get around the challenge of ES modules being static once resolved.
This would also support solving things like #1739, which we have long wanted to do.