node
node copied to clipboard
lib: add assertion for user ESM execution
Previously we only had an internal assertion to ensure certain code is executed before any user-provided CJS is run. This patch adds another assertion for ESM.
Note that this internal state is not updated during source text module execution via vm because to run any code via vm, some user JS code must have already been executed anyway.
In addition this patch moves the states into internal/modules/helpers to avoid circular dependencies. Also moves toggling the states to true right before user code execution instead of after in case we are half-way in the execution when internals try to check them.
Review requested:
- [ ] @nodejs/loaders
CI: https://ci.nodejs.org/job/node-test-pull-request/57162/
CI: https://ci.nodejs.org/job/node-test-pull-request/57211/
CI: https://ci.nodejs.org/job/node-test-pull-request/57221/
Landed in 0951e7b79d8509f6d80789109bb8d2e06bc130c3