Commit 8b26c7d3d73 for nodejs
commit 8b26c7d3d7345b44bef45757d0678ac7c8054df0
Author: Aditya Reddy <82123567+adityareddy-dev@users.noreply.github.com>
Date: Sat Nov 28 10:37:08 2026 -0600
doc: point require.extensions users to customization hooks
Signed-off-by: Aditya Reddy <82123567+adityareddy-dev@users.noreply.github.com>
PR-URL: https://github.com/nodejs/node/pull/67243
Fixes: https://github.com/nodejs/node/issues/32483
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md
index 65ad4578d6c..b6688ba20a6 100644
--- a/doc/api/deprecations.md
+++ b/doc/api/deprecations.md
@@ -937,6 +937,7 @@ changes:
Type: Documentation-only
The [`require.extensions`][] property is deprecated.
+Use [`module.registerHooks()`][] to customize module loading instead.
### DEP0040: `node:punycode` module
diff --git a/doc/api/modules.md b/doc/api/modules.md
index a0ce91d9f7f..81b2f06e17c 100644
--- a/doc/api/modules.md
+++ b/doc/api/modules.md
@@ -949,10 +949,9 @@ Process files with the extension `.sjs` as `.js`:
require.extensions['.sjs'] = require.extensions['.js'];
```
-**Deprecated.** In the past, this list has been used to load non-JavaScript
-modules into Node.js by compiling them on-demand. However, in practice, there
-are much better ways to do this, such as loading modules via some other Node.js
-program, or compiling them to JavaScript ahead of time.
+**Deprecated.** Use [`module.registerHooks()`][] to customize module loading
+instead. Its [synchronous customization hooks][] support both `require()` and
+`import`. Alternatively, compile non-JavaScript modules to JavaScript ahead of time.
Avoid using `require.extensions`. Use could cause subtle bugs and resolving the
extensions gets slower with each registered extension.
@@ -1302,6 +1301,7 @@ This section was moved to
[`module.builtinModules`]: module.md#modulebuiltinmodules
[`module.children`]: #modulechildren
[`module.id`]: #moduleid
+[`module.registerHooks()`]: module.md#moduleregisterhooksoptions
[`module` core module]: module.md
[`module` object]: #the-module-object
[`node:ffi`]: ffi.md
@@ -1319,3 +1319,4 @@ This section was moved to
[native addons]: addons.md
[subpath exports]: packages.md#subpath-exports
[subpath imports]: packages.md#subpath-imports
+[synchronous customization hooks]: module.md#synchronous-customization-hooks