module: add isPreloading indicator
Adds a module.isPreloading
property that is true
only during the
preload (-r
) phase of Node.js bootstrap. This provides modules an
easy, non-hacky way of knowing if they are being loaded during preload.
For example, sample.js
:
console.log(module.isPreloading);
$ node -r sample.js -pe ""
true
undefined
$ node sample.js
false
Signed-off-by: James M Snell jasnell@gmail.com
Checklist
-
make -j4 test
(UNIX), orvcbuild test
(Windows) passes -
tests and/or benchmarks are included -
documentation is changed or added -
commit message follows commit guidelines