-
-
Notifications
You must be signed in to change notification settings - Fork 33.5k
Description
What is the problem this feature will solve?
Some loaders, such as a mocking loader, should be aware of the thread initiating the operation. For example, it is common for ESM mocking to pass a list of export names to the loader thread, and later resolve those exports on an application thread. If a module is mocked from one application thread, and another thread tries to import the same module, it will be unaware of the export values. The export values themselves cannot be passed between threads because some values, such as function, do not serialize.
What is the feature you are proposing to solve the problem?
The resolve() loader hook already has a context object, which includes the parentURL. I am requesting that the thread ID also be included. If the thread ID were in the context, the resolve() hook could identify the proper mock (or real) implementation to use, depending on the thread.
What alternatives have you considered?
No response