Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport v14.x] module: add isPreloading indicator #36988

Closed

Conversation

aduh95
Copy link
Contributor

@aduh95 aduh95 commented Jan 18, 2021

Backport of #36263 and #36944.

Note that #36944 hasn't been released on a Current line for two weeks, but fixes a documentation bug which should land alongside #36263 IMHO.

jasnell and others added 2 commits January 18, 2021 23:41
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.

Signed-off-by: James M Snell <[email protected]>

PR-URL: nodejs#36263
Reviewed-By: Gerhard Stöbich <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Fixes: nodejs#36775

PR-URL: nodejs#36944
Refs: nodejs#36263
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Gerhard Stöbich <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@aduh95 aduh95 added module Issues and PRs related to the module subsystem. semver-minor PRs that contain new features and should be released in the next minor version. v14.x labels Jan 18, 2021
Comment on lines +223 to +225
ObjectDefineProperty(Module.prototype, 'isPreloading', {
get() { return isPreloading; }
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be a good idea to also backport NativeModule.prototype.isPreloading:

const isPreloadingDesc = { get() { return isPreloading; } };
ObjectDefineProperty(Module.prototype, 'isPreloading', isPreloadingDesc);
ObjectDefineProperty(NativeModule.prototype, 'isPreloading', isPreloadingDesc);

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

targos pushed a commit that referenced this pull request Apr 25, 2021
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.

Signed-off-by: James M Snell <[email protected]>

PR-URL: #36263
Backport-PR-URL: #36988
Reviewed-By: Gerhard Stöbich <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
targos pushed a commit that referenced this pull request Apr 25, 2021
Fixes: #36775

PR-URL: #36944
Backport-PR-URL: #36988
Refs: #36263
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Gerhard Stöbich <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@targos
Copy link
Member

targos commented Apr 25, 2021

Landed in 36abc18...7c9f3a9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module Issues and PRs related to the module subsystem. semver-minor PRs that contain new features and should be released in the next minor version.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants