Skip to content

Latest commit

 

History

History
9 lines (6 loc) · 782 Bytes

README.md

File metadata and controls

9 lines (6 loc) · 782 Bytes

This experiment creates a minimal, representative proof of concept for an asynchronous ESMLoader behaving synchronously. The most complex features of ESM are import.meta.resolve() and dynamic import() because both of them happen outside the initial module graph yet depend on it (some modules are stateful, like jest and testdouble), so the simplest solution would seamlessly persist state.

This uses a worker and Atomics. The Atomics serve as both the communication and data transport vehicles: the main sleeps whenever the worker is active, and the worker sleeps whenever the main is active.

Run the experiment:

node main.mjs