node icon indicating copy to clipboard operation
node copied to clipboard

lib: add assertion for user ESM execution

Open joyeecheung opened this issue 1 year ago • 1 comments

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.

joyeecheung avatar Feb 13 '24 13:02 joyeecheung

Review requested:

  • [ ] @nodejs/loaders

nodejs-github-bot avatar Feb 13 '24 13:02 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/57162/

nodejs-github-bot avatar Feb 17 '24 17:02 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/57211/

nodejs-github-bot avatar Feb 20 '24 18:02 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/57221/

nodejs-github-bot avatar Feb 20 '24 22:02 nodejs-github-bot

Landed in 0951e7b79d8509f6d80789109bb8d2e06bc130c3

nodejs-github-bot avatar Feb 21 '24 01:02 nodejs-github-bot