Skip to content

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), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

Merge request reports

Loading