mirror of
https://github.com/nodejs/node.git
synced 2026-11-25 23:01:06 -05:00
doc: add performance warning to require.extensions
Discourage using require.extensions because it slows down the module loader. The number of file system operations that the module system has to perform in order to resolve a `require(...)` statement to a filename is proportional to the number of registered extensions. PR-URL: https://github.com/nodejs/node/pull/9196 Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
1 parent
60a5b515b8
commit
ce00a9d2b6
1 file changed
+8
-1
+8
-1
@@ -216,10 +216,17 @@ 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.
|
||||
|
||||
Since the Module system is locked, this feature will probably never go
|
||||
Since the module system is locked, this feature will probably never go
|
||||
away. However, it may have subtle bugs and complexities that are best
|
||||
left untouched.
|
||||
|
||||
Note that the number of file system operations that the module system
|
||||
has to perform in order to resolve a `require(...)` statement to a
|
||||
filename scales linearly with the number of registered extensions.
|
||||
|
||||
In other words, adding extensions slows down the module loader and
|
||||
should be discouraged.
|
||||
|
||||
### require.resolve()
|
||||
<!-- YAML
|
||||
added: v0.3.0
|
||||
|
||||
Reference in new issue
Block a user