Joyee Cheung
916929863d
esm: populate separate cache for require(esm) in imported CJS
...
Otherwise if the ESM happens to be cached separately by the ESM loader
before it gets loaded with `require(esm)` from within an imported
CJS file (which uses a re-invented require() with a couple of quirks,
including a separate cache), it won't be able to load the esm properly
from the cache.
PR-URL: https://github.com/nodejs/node/pull/59679
Refs: https://github.com/nodejs/node/issues/59666
Refs: https://github.com/nodejs/node/issues/52697
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Chengzhong Wu <legendecas@gmail.com >
2025-09-08 14:59:31 +00:00
Joyee Cheung
3ffc3d73ac
esm: fix missed renaming in ModuleJob.runSync
...
https://redirect.github.com/nodejs/node/pull/59675 missed a case
when renaming .async to .hasAsyncGraph. This fixes that and add
a test that would previously crash with the missed rename.
PR-URL: https://github.com/nodejs/node/pull/59724
Refs: https://github.com/nodejs/node/pull/59675
Reviewed-By: Chengzhong Wu <legendecas@gmail.com >
Reviewed-By: Ulises Gascón <ulisesgascongonzalez@gmail.com >
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com >
2025-09-04 10:01:32 +00:00
Joyee Cheung
fb22c7f414
src: separate module.hasAsyncGraph and module.hasTopLevelAwait
...
Clarify the names - hasAsyncGraph means either the module or its
dependencies contains top-level await; hasTopLevelAwait means the
module itself contains top-level await. Theoratically the former
can be inferred from iterating over the dependencies but for the
built-in loader it's currently not fully reliable until we eliminate
async linking.
Also remove the hasTopLevelAwait method - we can simply put it
on the module wrap for source text modules right after compilation.
PR-URL: https://github.com/nodejs/node/pull/59675
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Chengzhong Wu <legendecas@gmail.com >
2025-09-01 14:59:04 +00:00
René
196f5466af
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-08-30 14:28:10 +00:00
Joyee Cheung
7535aa1f72
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-08-20 14:31:08 +00:00
Joyee Cheung
db70ceb49f
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-08-20 14:31:08 +00:00
Joyee Cheung
af5d1c93ce
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-08-14 14:28:40 +00:00
Joyee Cheung
6ea421a3d3
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-07-26 09:13:11 +00:00
Guy Bedford
0df15188d7
esm: unflag --experimental-wasm-modules
...
PR-URL: https://github.com/nodejs/node/pull/57038
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-07-22 13:24:06 -07:00
Ilyas Shabi
2a7fb0a680
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-07-21 15:26:02 +00:00
Guy Bedford
35e599b3d0
esm: js-string Wasm builtins in ESM Integration
...
PR-URL: https://github.com/nodejs/node/pull/59020
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Chengzhong Wu <legendecas@gmail.com >
2025-07-18 15:50:52 -07:00
Yagiz Nizipli
0fd1ecded6
meta: enable jsdoc/check-tag-names rule
...
PR-URL: https://github.com/nodejs/node/pull/58521
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: LiviaMedeiros <livia@cirno.name >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2025-07-18 09:28:21 +00:00
Joyee Cheung
793a2792d5
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-07-09 16:39:29 +00:00
Chengzhong Wu
cc856b3d5d
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
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-07-04 19:56:08 +00:00
沈鸿飞
b4c5fb4ffb
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-06-26 07:04:40 +00:00
Alex Yang and Joyee Cheung
a705e240b1
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-06-25 16:49:56 +00:00
Mert Can Altin
6ce6fdbf21
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-06-24 21:49:31 +00:00
Marco Ippolito
bba07d7e1e
module: fix typescript import.meta.main
...
PR-URL: https://github.com/nodejs/node/pull/58661
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-06-12 11:21:54 +00:00
Marco Ippolito
708477bd8d
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
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 >
2025-06-12 06:35:21 +00:00
Jacob Smith
5e1537c30b
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-06-11 21:53:56 +00:00
Marco Ippolito
6584d5f811
module: remove experimental warning from type stripping
...
PR-URL: https://github.com/nodejs/node/pull/58643
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 >
2025-06-11 10:12:04 +00:00
Joyee Cheung
8c17ceb38f
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-06-11 09:33:16 +00:00
James M Snell
705bcc2a00
module: move Module._debug to end-of-life
...
Was runtime deprecated 7 years ago. Probably safe to remove now.
PR-URL: https://github.com/nodejs/node/pull/58473
Reviewed-By: Chengzhong Wu <legendecas@gmail.com >
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com >
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Filip Skokan <panva.ip@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
2025-05-30 17:22:59 -07:00
Chengzhong Wu
7ffa029750
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-05-30 09:47:20 +00:00
Guy Bedford
a7e4a40298
esm: unwrap WebAssembly.Global on Wasm Namespaces
...
PR-URL: https://github.com/nodejs/node/pull/57525
Reviewed-By: Jacob Smith <jacob@frende.me >
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
2025-05-27 11:40:28 -07:00
Joe and Antoine du Hamel
bbc059378b
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
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-05-26 22:31:54 +00:00
Aditi
6f045771fa
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-05-26 21:19:23 +00:00
Chengzhong Wu
a436f7b492
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-05-16 19:40:17 +00:00
Carlos Espa
b6189c352c
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-05-16 06:39:28 +00:00
Joyee Cheung
e0766f9a73
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-05-08 20:10:32 +00:00
Antoine du Hamel
50cfc6ca63
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-04-29 22:55:33 +02:00
Yagiz Nizipli
5ed1bcbd9b
src: fix internalModuleStat v8 fast path
...
PR-URL: https://github.com/nodejs/node/pull/58054
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Robert Nagy <ronagy@icloud.com >
2025-04-29 17:53:12 +00:00
haykam821
bc09144aa6
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-04-09 11:47:58 +00:00
Dario Piotrowicz
8c254658bb
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-04-06 07:47:53 +00:00
Dario Piotrowicz
d7a1565350
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-04-06 07:47:45 +00:00
Guy Bedford
870dec25f7
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-04-03 19:38:40 -07:00
Marco Ippolito
0dc4725909
deps: update amaro to 0.5.1
...
PR-URL: https://github.com/nodejs/node/pull/57704
Reviewed-By: Jacob Smith <jacob@frende.me >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2025-04-03 12:00:52 +00:00
Marco Ippolito
1c2d98d380
module: improve typescript error message format
...
PR-URL: https://github.com/nodejs/node/pull/57687
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 >
2025-04-01 11:16:48 +00:00
Gürgün Dayıoğlu
a20acd407d
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-03-18 15:52:50 +00:00
Guy Bedford
fbe37d501e
esm: fix module.exports export on CJS modules
...
PR-URL: https://github.com/nodejs/node/pull/57366
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2025-03-09 13:51:04 -07:00
Joyee Cheung
0aa3dddfeb
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-03-04 07:34:34 +00:00
Guy Bedford
db4dcc05ac
esm: support source phase imports for WebAssembly
...
PR-URL: https://github.com/nodejs/node/pull/56919
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com >
2025-02-28 09:52:47 -08:00
Chengzhong Wu
90ab559f4d
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-02-21 18:06:34 +01:00
Joyee Cheung
8d10bc7b09
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-02-20 17:22:08 +00:00
Joyee Cheung
ea2004a2ac
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-02-18 15:28:59 +00:00
Aditi
5dafb48f1a
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-02-11 15:24:02 +00:00
James M Snell
2972fe961b
lib: filter node:quic from builtinModules when flag not used
...
PR-URL: https://github.com/nodejs/node/pull/56870
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com >
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com >
Reviewed-By: Jordan Harband <ljharb@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2025-02-03 19:14:06 +00:00
Dario Piotrowicz
7119303a81
module: fix bad require.resolve with option paths for . and ..
...
this change fixes `require.resolve` used with the `paths` option
not considering `.` and `..` as relative
Fixes: https://github.com/nodejs/node/issues/47000
PR-URL: https://github.com/nodejs/node/pull/56735
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Jordan Harband <ljharb@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2025-01-25 23:32:13 +00:00
Joyee Cheung
4a5d2c7538
module: integrate TypeScript into compile cache
...
This integrates TypeScript into the compile cache by caching
the transpilation (either type-stripping or transforming) output
in addition to the V8 code cache that's generated from the
transpilation output.
Locally this speeds up loading with type stripping of
`benchmark/fixtures/strip-types-benchmark.ts` by ~65% and
loading with type transforms of
`fixtures/transform-types-benchmark.ts` by ~128%.
When comparing loading .ts and loading pre-transpiled .js on-disk
with the compile cache enabled, previously .ts loaded 46% slower
with type-stripping and 66% slower with transforms compared to
loading .js files directly.
After this patch, .ts loads 12% slower with type-stripping and
22% slower with transforms compared to .js.
(Note that the numbers are based on microbenchmark fixtures and
do not necessarily represent real-world workloads, though with
bigger real-world files, the speed up should be more significant).
PR-URL: https://github.com/nodejs/node/pull/56629
Fixes: https://github.com/nodejs/node/issues/54741
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2025-01-25 02:30:27 +00:00
Chengzhong Wu
b11ee4cad3
lib: allow skipping source maps in node_modules
...
Files in `node_modules` are not authored by the user directly and the
original sources are less relevant to the user.
Skipping source maps in `node_modules` improves the general
performance. Add `module.setSourceMapsSupport(enabled, options)` to
skip source maps in `node_modules` if it is needed. This moves
all source maps related API to `node:module` and this a step to
promote the source maps API to stable.
PR-URL: https://github.com/nodejs/node/pull/56639
Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2025-01-23 22:44:10 +00:00