require.extensions
稳定性: 0 - 弃用
指导 require
如何处理某些文件扩展名。
将扩展名为 .sjs
的文件处理为 .js
:
require.extensions['.sjs'] = require.extensions['.js'];
已弃用。 过去,此列表用于通过按需编译将非 JavaScript 模块加载到 Node.js 中。 但是,在实践中,有很多更好的方法可以做到这一点,例如通过其他一些 Node.js 程序加载模块,或者提前将它们编译为 JavaScript。
避免使用 require.extensions
。
使用可能会导致细微的错误,并且每个注册的扩展程序解决扩展程序的速度都会变慢。
Stability: 0 - Deprecated
Instruct require
on how to handle certain file extensions.
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.
Avoid using require.extensions
. Use could cause subtle bugs and resolving the
extensions gets slower with each registered extension.