Craig Macomber (Microsoft)
dda95e91b9
esm: avoid throw when module specifier is not url
...
This particular exception is responsible for a lot of overhead when
debugging with large esm codebases with VS Code and break on caught
exceptions is enabled.
VS Code silently suppresses this exception, but the mechanism it uses
to do so is a bit slow so avoiding this common exception can speed up
loading of esm code.
In my scenario this saved over have of the startup run time
(over 20 seconds).
This should also make debugging without suppression of this exception
more pleasant in other tools such as the Chrome dev tools when
attached to NodeJs processes.
PR-URL: https://github.com/nodejs/node/pull/61000
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Jacob Smith <jacob@frende.me >
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
2026-02-24 00:37:11 +01:00
Joyee Cheung
8674f6527f
module: preserve URL in the parent created by createRequire()
...
Previously, createRequire() does not preserve the URL it gets
passed in the mock parent module created, which can be
observable if it's used together with module.registerHooks().
This patch adds preservation of the URL if createRequire()
is invoked with one.
PR-URL: https://github.com/nodejs/node/pull/60974
Fixes: https://github.com/nodejs/node/issues/60973
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
2026-02-17 15:14:21 +01:00
Chengzhong Wu
705832a1be
lib,src: isInsideNodeModules should test on the first non-internal frame
...
PR-URL: https://github.com/nodejs/node/pull/60991
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com >
Reviewed-By: Daniel Lemire <daniel@lemire.me >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
2026-02-17 15:14:07 +01:00
Michael Smith
36b68db7f5
src: reduce the nearest parent package JSON cache size
...
PR-URL: https://github.com/nodejs/node/pull/59888
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com >
Reviewed-By: Edy Silva <edigleyssonsilva@gmail.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
2025-10-07 17:29:38 +02:00
Chengzhong Wu
2237142369
module: link module with a module request record
...
When a module is being statically linked with module requests, if two
module requests with a same specifier but different attributes are
resolved to two modules, the module requests should be linked to these
two modules.
PR-URL: https://github.com/nodejs/node/pull/58886
Backport-PR-URL: https://github.com/nodejs/node/pull/60000
Refs: https://tc39.es/ecma262/#sec-HostLoadImportedModule
Refs: https://github.com/tc39/proposal-import-attributes?tab=readme-ov-file#how-would-this-proposal-work-with-caching
Reviewed-By: Guy Bedford <guybedford@gmail.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
2025-10-07 16:08:51 +02:00
Chengzhong Wu
d302cb3bb2
esm: add experimental support for addon modules
...
PR-URL: https://github.com/nodejs/node/pull/55844
Backport-PR-URL: https://github.com/nodejs/node/pull/59961
Fixes: https://github.com/nodejs/node/issues/40541
Fixes: https://github.com/nodejs/node/issues/55821
Reviewed-By: Guy Bedford <guybedford@gmail.com >
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: Jacob Smith <jacob@frende.me >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2025-09-22 14:28:01 +00:00
René
10ae8684ea
lib: revert to using default derived class constructors
...
PR-URL: https://github.com/nodejs/node/pull/59650
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2025-09-20 06:16:14 +00:00
Joyee Cheung
d55c3e7f0b
esm: link modules synchronously when no async loader hooks are used
...
When no async loader hooks are registered, perform the linking as
synchronously as possible to reduce the chance of races from the
the shared module loading cache.
PR-URL: https://github.com/nodejs/node/pull/59519
Fixes: https://github.com/nodejs/node/issues/59366
Refs: https://github.com/abejfehr/node-22.18-issue-repro
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
Reviewed-By: Filip Skokan <panva.ip@gmail.com >
Reviewed-By: Chengzhong Wu <legendecas@gmail.com >
2025-09-20 04:32:39 +00:00
Joyee Cheung
9e1fbb620f
esm: show race error message for inner module job race
...
The race can not only happen when the ESM is loaded by
the CommonJS loader, but can also happen to inner
module jobs in the dependency graph.
PR-URL: https://github.com/nodejs/node/pull/59519
Fixes: https://github.com/nodejs/node/issues/59366
Refs: https://github.com/abejfehr/node-22.18-issue-repro
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
Reviewed-By: Filip Skokan <panva.ip@gmail.com >
Reviewed-By: Chengzhong Wu <legendecas@gmail.com >
2025-09-20 04:32:37 +00:00
Joyee Cheung
8c4dcd5199
esm: sync-ify module translation
...
This completes the TODO to compile WASM synchronously and thus
making translation (i.e. compilation + instantiation) synchronous.
PR-URL: https://github.com/nodejs/node/pull/59453
Refs: https://github.com/nodejs/node/issues/55782
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Chengzhong Wu <legendecas@gmail.com >
2025-09-20 03:33:20 +00:00
Guy Bedford
fa9a9e9c69
esm: unflag --experimental-wasm-modules
...
PR-URL: https://github.com/nodejs/node/pull/57038
Backport-PR-URL: https://github.com/nodejs/node/pull/59179
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com >
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
Reviewed-By: Chengzhong Wu <legendecas@gmail.com >
2025-08-27 00:55:20 +02:00
Guy Bedford
177ed3b3dd
esm: js-string Wasm builtins in ESM Integration
...
PR-URL: https://github.com/nodejs/node/pull/59020
Backport-PR-URL: https://github.com/nodejs/node/pull/59179
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Chengzhong Wu <legendecas@gmail.com >
2025-08-27 00:55:18 +02:00
Joyee Cheung
0eec5cc492
module: fix conditions override in synchronous resolve hooks
...
1. Make sure that the conditions are converted into arrays when
being passed into user hooks.
2. Pass the conditions from user hooks into the ESM resolution
so that it takes effect.
PR-URL: https://github.com/nodejs/node/pull/59011
Fixes: https://github.com/nodejs/node/issues/59003
Reviewed-By: Zeyu "Alex" Yang <himself65@outlook.com >
Reviewed-By: Jacob Smith <jacob@frende.me >
2025-08-20 17:11:45 +02:00
Joyee Cheung
4acf7cd6d3
module: throw error when re-runing errored module jobs
...
Re-evaluating an errored ESM should lead to rejecting
the rejection again - this is also the case when importing
it twice. In the case of retrying with
require after import, just throw the cached error.
Drive-by: add some debug logs.
PR-URL: https://github.com/nodejs/node/pull/58957
Fixes: https://github.com/nodejs/node/issues/58945
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2025-08-20 16:23:54 +02:00
Ilyas Shabi
c637a2c41d
src: add cache to nearest parent package json
...
PR-URL: https://github.com/nodejs/node/pull/59086
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: Jacob Smith <jacob@frende.me >
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com >
2025-08-04 13:35:50 +02:00
Yagiz Nizipli
390654e996
src: fix internalModuleStat v8 fast path
...
PR-URL: https://github.com/nodejs/node/pull/58054
Backport-PR-URL: https://github.com/nodejs/node/pull/59065
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Robert Nagy <ronagy@icloud.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2025-07-28 08:58:22 +02:00
Marco Ippolito
2fc89892ab
module: fix typescript import.meta.main
...
PR-URL: https://github.com/nodejs/node/pull/58661
Backport-PR-URL: https://github.com/nodejs/node/pull/58693
Fixes: https://github.com/nodejs/node/issues/58660
Reviewed-By: Xuguang Mei <meixuguang@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Jacob Smith <jacob@frende.me >
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev >
Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com >
Reviewed-By: Chemi Atlow <chemi@atlow.co.il >
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
2025-07-28 08:46:20 +02:00
Joe and Antoine du Hamel
430e66b9b8
esm: implement import.meta.main
...
Boolean value to check if an ES Module is the entrypoint of the
current process.
Implements: #57226
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/57804
Backport-PR-URL: https://github.com/nodejs/node/pull/58693
Fixes: https://github.com/nodejs/node/issues/57226
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Guy Bedford <guybedford@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com >
2025-07-28 08:46:16 +02:00
沈鸿飞
79428d8946
lib: fix getTypeScriptParsingMode jsdoc
...
PR-URL: https://github.com/nodejs/node/pull/58681
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com >
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
2025-07-24 20:08:27 +02:00
Alex Yang and Joyee Cheung
bfc68c8ae8
module: convert schema-only core module on convertCJSFilenameToURL
...
Co-authored-by: Joyee Cheung <joyeec9h3@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/58612
Fixes: https://github.com/nodejs/node/issues/58607
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
2025-07-24 20:08:27 +02:00
Mert Can Altin
54634f5e53
module: update tests for combined ambiguous module syntax error
...
PR-URL: https://github.com/nodejs/node/pull/55874
Fixes: https://github.com/nodejs/node/issues/55776
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
2025-07-24 20:08:27 +02:00
Jacob Smith
42c4ca6024
esm: syncify default path of ModuleLoader.load
...
PR-URL: https://github.com/nodejs/node/pull/57419
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
2025-07-24 20:08:21 +02:00
Joyee Cheung
10eb3db4af
module: allow cycles in require() in the CJS handling in ESM loader
...
When --import is used, the ESM loader is used to handle even pure
CJS entry points, and it can run into CJS module facades in the
evaluating state when the parent CJS module is being evaluated.
In this case it should be allowed, since the ESM <-> CJS cycles
that are meant to be disallowed (for the time being) should
already be detected before evaluation and wouldn't get here,
and CJS <-> CJS cycles are fine.
PR-URL: https://github.com/nodejs/node/pull/58598
Fixes: https://github.com/nodejs/node/issues/58515
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev >
2025-07-24 20:08:21 +02:00
Guy Bedford
3ac8c686a3
esm: unwrap WebAssembly.Global on Wasm Namespaces
...
PR-URL: https://github.com/nodejs/node/pull/57525
Backport-PR-URL: https://github.com/nodejs/node/pull/58745
Reviewed-By: Jacob Smith <jacob@frende.me >
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
2025-07-21 16:29:31 +02:00
Marco Ippolito
81a10a67d5
deps: update amaro to 0.5.1
...
PR-URL: https://github.com/nodejs/node/pull/57704
Backport-PR-URL: https://github.com/nodejs/node/pull/57298
Reviewed-By: Jacob Smith <jacob@frende.me >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/56350
Fixes: https://github.com/nodejs/typescript/issues/17
2025-07-15 19:03:11 -03:00
Marco Ippolito
fe7994eb0c
module: improve typescript error message format
...
PR-URL: https://github.com/nodejs/node/pull/57687
Backport-PR-URL: https://github.com/nodejs/node/pull/57298
Fixes: https://github.com/nodejs/node/issues/56830
Reviewed-By: Chengzhong Wu <legendecas@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com >
PR-URL: https://github.com/nodejs/node/pull/56350
Fixes: https://github.com/nodejs/typescript/issues/17
2025-07-15 19:03:11 -03:00
Marco Ippolito
c898491017
module: remove experimental warning from type stripping
...
PR-URL: https://github.com/nodejs/node/pull/58643
Backport-PR-URL: https://github.com/nodejs/node/pull/57298
Refs: https://github.com/nodejs/typescript/issues/24
Reviewed-By: Jacob Smith <jacob@frende.me >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Jordan Harband <ljharb@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Filip Skokan <panva.ip@gmail.com >
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev >
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com >
Reviewed-By: Chengzhong Wu <legendecas@gmail.com >
Reviewed-By: Chemi Atlow <chemi@atlow.co.il >
PR-URL: https://github.com/nodejs/node/pull/56350
Fixes: https://github.com/nodejs/typescript/issues/17
2025-07-15 19:03:11 -03:00
Marco Ippolito
c07745a436
module: refactor commonjs typescript loader
...
This commit refactors the CommonJS loader to remove TypeScript-specific
extensions from the require.extensions object for compatibility with
libraries that depended on it to initialize extenal TypeScript loaders.
PR-URL: https://github.com/nodejs/node/pull/58657
Backport-PR-URL: https://github.com/nodejs/node/pull/57298
Refs: https://github.com/nodejs/typescript/issues/37
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com >
Reviewed-By: Xuguang Mei <meixuguang@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/56350
Fixes: https://github.com/nodejs/typescript/issues/17
2025-07-15 19:03:11 -03:00
Chengzhong Wu
72a1b061f3
fs: unexpose internal constants
...
`EXTENSIONLESS_FORMAT_JAVASCRIPT` and `EXTENSIONLESS_FORMAT_WASM` are
only used internally through binding `getFormatOfExtensionlessFile`.
They should not be exposed publicly.
PR-URL: https://github.com/nodejs/node/pull/58327
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: LiviaMedeiros <livia@cirno.name >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com >
2025-06-10 16:55:45 +02:00
Joyee Cheung
4cc4195493
module: handle instantiated async module jobs in require(esm)
...
When require(esm) encounters a cached module job that is instantiated
but not yet evaluated, run the evaluation. This catches an edge case
previously missed in https://github.com/nodejs/node/pull/57187 .
PR-URL: https://github.com/nodejs/node/pull/58067
Fixes: https://github.com/nodejs/node/issues/58061
Reviewed-By: Jacob Smith <jacob@frende.me >
2025-06-10 16:38:57 +02:00
Chengzhong Wu
a5df778150
src,lib: obtain sourceURL in magic comments from V8
...
Obtain sourceURL magic comments via V8 API to avoid a second round of
extraction of magic comments.
Updates source map snapshot normalization to allow testing full path
names inside the test outputs.
PR-URL: https://github.com/nodejs/node/pull/58389
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
2025-06-10 15:10:12 +02:00
Aditi
0cea14ec7f
errors: show url of unsupported attributes in the error message
...
PR-URL: https://github.com/nodejs/node/pull/58303
Fixes: https://github.com/nodejs/node/issues/56930
Reviewed-By: Jacob Smith <jacob@frende.me >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
2025-06-10 14:52:22 +02:00
Carlos Espa
72fac71b92
module: clarify cjs global-like error on ModuleJobSync
...
PR-URL: https://github.com/nodejs/node/pull/56491
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: Jacob Smith <jacob@frende.me >
2025-06-10 14:52:16 +02:00
Michaël Zasso
4e02a1650a
lib: remove unused file fetch_module
...
PR-URL: https://github.com/nodejs/node/pull/55880
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Jacob Smith <jacob@frende.me >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Chemi Atlow <chemi@atlow.co.il >
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com >
2025-05-19 12:14:12 +02:00
Jacob Smith
021b174a1f
module: tidy code string concat → string templates
...
PR-URL: https://github.com/nodejs/node/pull/55820
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2025-05-19 12:14:12 +02:00
Antoine du Hamel
bef06b11df
esm: avoid import.meta setup costs for unused properties
...
PR-URL: https://github.com/nodejs/node/pull/57286
Reviewed-By: Jacob Smith <jacob@frende.me >
Reviewed-By: Edy Silva <edigleyssonsilva@gmail.com >
2025-05-19 12:14:09 +02:00
haykam821
44c5718476
module: fix incorrect formatting in require(esm) cycle error message
...
Fixes: https://github.com/nodejs/node/issues/57451
PR-URL: https://github.com/nodejs/node/pull/57453
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: Jake Yuesong Li <jake.yuesong@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2025-05-19 12:13:55 +02:00
Dario Piotrowicz
bb09b4d4ae
module: improve getPackageType performance
...
PR-URL: https://github.com/nodejs/node/pull/57599
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Ulises Gascón <ulisesgascongonzalez@gmail.com >
2025-05-19 12:13:52 +02:00
Dario Piotrowicz
9e6054e715
module: remove unnecessary readPackage function
...
PR-URL: https://github.com/nodejs/node/pull/57596
Reviewed-By: Jacob Smith <jacob@frende.me >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Darshan Sen <raisinten@gmail.com >
2025-05-19 12:13:52 +02:00
Guy Bedford
832640c35e
esm: support top-level Wasm without package type
...
PR-URL: https://github.com/nodejs/node/pull/57610
Reviewed-By: Jordan Harband <ljharb@gmail.com >
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2025-05-19 12:13:50 +02:00
Gürgün Dayıoğlu
cc4d33842b
lib: limit split function calls to prevent excessive array length
...
PR-URL: https://github.com/nodejs/node/pull/57501
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Jacob Smith <jacob@frende.me >
2025-04-17 10:51:46 -03:00
Joyee Cheung
3ceda2a035
module: handle cached linked async jobs in require(esm)
...
This handles two cases caused by using Promise.all() with
multiple dynamic import() that can make an asynchronously
linked module job that has finished/failed linking but
has not yet started actual evaluation appear in the load
cache when another require request is in turn to handle
it.
- When the cached async job has finished linking but has not
started its evaluation because the async run() task would be
later in line, start the evaluation from require() with
runSync().
- When the cached async job have already encountered a linking
error that gets wrapped into a rejection, but is still later
in line to throw on it, just unwrap and throw the linking error
from require().
PR-URL: https://github.com/nodejs/node/pull/57187
Fixes: https://github.com/nodejs/node/issues/57172
Refs: https://github.com/shufo/prettier-plugin-blade/issues/311
Refs: https://github.com/fisker/prettier-plugin-blade-311
Refs: https://github.com/mochajs/mocha/issues/5290
Refs: https://github.com/JoshuaKGoldberg/repros/tree/mocha-missing-module-cyclic
Reviewed-By: Guy Bedford <guybedford@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2025-04-17 10:51:19 -03:00
Chengzhong Wu
6dab980fab
typings: fix ImportModuleDynamicallyCallback return type
...
PR-URL: https://github.com/nodejs/node/pull/57160
Refs: https://github.com/nodejs/node/pull/56919/files#r1955336054
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2025-04-17 10:51:03 -03:00
Joyee Cheung
d1845edd21
module: improve error message from asynchronicity in require(esm)
...
- Improve the error message that shows up when there is a race
from doing require(esm) and import(esm) at the same time.
- Improve error message of ERR_REQUIRE_ASYNC_MODULE by showing
parent and target file names, if available.
Drive-by: split the require(tla) tests since we are modifying
the tests already.
PR-URL: https://github.com/nodejs/node/pull/57126
Refs: https://github.com/fisker/prettier-issue-17139
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Chengzhong Wu <legendecas@gmail.com >
2025-04-17 10:51:02 -03:00
Joyee Cheung
41fa7d3c21
module: allow omitting context in synchronous next hooks
...
This aligns the behavior of synchronous hooks with asynchronous
hooks by allowing omission of the context parameter in the
invocation of next hooks. The contexts are merged along the
chain.
PR-URL: https://github.com/nodejs/node/pull/57056
Fixes: https://github.com/nodejs/node/issues/57030
Reviewed-By: Jacob Smith <jacob@frende.me >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2025-04-17 10:50:58 -03:00
Aditi
deddecce3a
module: fix require.resolve() crash on non-string paths
...
Previously, `require.resolve()` could crash when:
- The first parameter was a relative path and
- The `paths` array contained non-string entries
This commit fixes the issue by adding a check in
`Module._findPath` to ensure all elements in `paths`
are strings, and adding a validation in `stat` before
calling `InternalModuleStat` to guard against
non-string filenames.
PR-URL: https://github.com/nodejs/node/pull/56942
Fixes: https://github.com/nodejs/node/issues/47698
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
2025-04-17 10:50:47 -03:00
Vitalii Akimov
926b887534
module: fixing url change in load sync hook chain
...
Fixes: https://github.com/nodejs/node/issues/56376
PR-URL: https://github.com/nodejs/node/pull/56402
Backport-PR-URL: https://github.com/nodejs/node/pull/57130
Reviewed-By: Jacob Smith <jacob@frende.me >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2025-03-31 20:38:24 -03:00
Jacob Smith
eff42956c4
doc: correct customization hook types & clarify descriptions
...
PR-URL: https://github.com/nodejs/node/pull/56454
Backport-PR-URL: https://github.com/nodejs/node/pull/57130
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2025-03-31 20:38:20 -03:00
Joyee Cheung
6b93ba723b
module: use synchronous hooks for preparsing in import(cjs)
...
PR-URL: https://github.com/nodejs/node/pull/55698
Backport-PR-URL: https://github.com/nodejs/node/pull/57130
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
Reviewed-By: Chengzhong Wu <legendecas@gmail.com >
Reviewed-By: Guy Bedford <guybedford@gmail.com >
2025-03-31 20:38:16 -03:00
Joyee Cheung
b2e44a8079
module: implement module.registerHooks()
...
PR-URL: https://github.com/nodejs/node/pull/55698
Backport-PR-URL: https://github.com/nodejs/node/pull/57130
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
Reviewed-By: Chengzhong Wu <legendecas@gmail.com >
Reviewed-By: Guy Bedford <guybedford@gmail.com >
2025-03-31 20:38:09 -03:00