node/lib/internal/modules/esm
Joyee Cheung 8aac7da7d6
module: fix error thrown from require(esm) hitting TLA repeatedly
This tracks the asynchronicity in the ModuleWraps when they turn out to
contain TLA after instantiation, and throw the right error
(ERR_REQUIRE_ASYNC_MODULE) when it's required again. It removes
the freezing of ModuleWraps since it's not meaningful to freeze
this when the rest of the module loader is mutable, and we
can record the asynchronicity in the ModuleWrap right after
compilation after we get a V8 upgrade that contains
v8::Module::HasTopLevelAwait() instead of searching through
the module graph repeatedly which can be slow.

PR-URL: https://github.com/nodejs/node/pull/55520
Fixes: https://github.com/nodejs/node/issues/55516
Refs: https://github.com/nodejs/node/issues/52697
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Jacob Smith <jacob@frende.me>
2024-10-29 21:15:19 +00:00
..
assert.js lib,doc: replace references to import assertions 2024-05-17 08:07:48 +00:00
create_dynamic_module.js module: centralize SourceTextModule compilation for builtin loader 2024-04-03 23:31:48 +00:00
fetch_module.js lib: remove startsWith/endsWith primordials for char checks 2024-10-19 10:18:10 +00:00
formats.js module: add --experimental-strip-types 2024-07-24 16:30:06 +00:00
get_format.js module: add module.stripTypeScriptTypes 2024-10-24 18:27:58 +00:00
hooks.js esm: fix inconsistency with `importAssertion` in `resolve` hook 2024-10-15 21:02:07 +02:00
initialize_import_meta.js tools: add lint rule to keep primordials in ASCII order 2024-04-21 16:53:08 +00:00
load.js module: simplify ts under node_modules check 2024-10-20 09:09:56 +00:00
loader.js module: fix error thrown from require(esm) hitting TLA repeatedly 2024-10-29 21:15:19 +00:00
module_job.js module: fix error thrown from require(esm) hitting TLA repeatedly 2024-10-29 21:15:19 +00:00
module_map.js lib,doc: replace references to import assertions 2024-05-17 08:07:48 +00:00
resolve.js module: add `findPackageJSON` util 2024-10-25 20:40:54 +00:00
shared_constants.js esm: move hook execution to separate thread 2023-04-13 09:35:17 +02:00
translators.js module: add module.stripTypeScriptTypes 2024-10-24 18:27:58 +00:00
utils.js module: unflag --experimental-require-module 2024-09-26 14:21:37 +00:00
worker.js Revert "module: have a single hooks thread for all workers" 2024-06-02 22:10:34 +00:00