-
Notifications
You must be signed in to change notification settings - Fork 30k
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
lib: refactor NativeModule #30856
lib: refactor NativeModule #30856
Conversation
Refactor the internal NativeModule class to a JS class and add more documentation about its properties.
this.canBeRequiredByUsers = !id.startsWith('internal/'); | ||
|
||
// The CJS exports object of the module. | ||
this.exports = {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't a public (or maybe private) field declaration be preferable?
class NativeModule {
exports = {};
#loaded = false;
#loading = false;
module = undefined;
exportKeys = undefined;
}
I personally find it more readable than a declaration in the constructor, but that might just be me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't mind if private fields are used but i think we should keep field initialization in one spot (in this case, the constructor, since it assigns from arguments).
Landed in e4e5a83 |
Refactor the internal NativeModule class to a JS class and add more documentation about its properties. PR-URL: #30856 Reviewed-By: Denys Otrishko <[email protected]> Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: Rich Trott <[email protected]>
Refactor the internal NativeModule class to a JS class and add more documentation about its properties. PR-URL: #30856 Reviewed-By: Denys Otrishko <[email protected]> Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: Rich Trott <[email protected]>
Refactor the internal NativeModule class to a JS class and add more documentation about its properties. PR-URL: #30856 Reviewed-By: Denys Otrishko <[email protected]> Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: Rich Trott <[email protected]>
Refactor the internal NativeModule class to a JS class and add more documentation about its properties. PR-URL: #30856 Reviewed-By: Denys Otrishko <[email protected]> Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: Rich Trott <[email protected]>
Refactor the internal NativeModule class to a JS class and add
more documentation about its properties.
Tip: https://github.com/nodejs/node/pull/30856/files?w=1 is easier to review
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes