Browse Source

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>
v7.x
Ben Noordhuis 8 years ago
committed by Evan Lucas
parent
commit
ce00a9d2b6
  1. 9
      doc/api/globals.md

9
doc/api/globals.md

@ -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

Loading…
Cancel
Save