-
- Notifications
You must be signed in to change notification settings - Fork 33.7k
modules: add setter for module.parent #35522
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
Conversation
| Review requested:
|
bmeck left a comment
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.
LGTM pending lint
richardlau left a comment
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.
From the CITGM results that have completed this has fixed the node-gyp test suite, thanks.
137222b to 80384e8 Compare This comment has been minimized.
This comment has been minimized.
| BTW, this should have the label |
This comment has been minimized.
This comment has been minimized.
| My only issue with converting |
lib/internal/modules/cjs/loader.js Outdated
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.
Make delete work:
| ) : setModuleParent, | |
| ) : setModuleParent, | |
| configurable: true, |
| @ExE-Boss making the property configurable should make delete work. |
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.
| module.parent = undefined; | |
| module.parent = undefined; | |
| delete module.parent; | |
| assert.strictEqual('parent' in module, false); |
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.
| const common = require('../common'); | |
| const common = require('../common'); | |
| const assert = require('assert'); |
lib/internal/modules/cjs/loader.js Outdated
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.
moving this to be on the module itself is needed to make delete work
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 that trigger a new deprecation warning for each Module instance?
module.parent; // triggers one warning module.parent?.parent; // triggers another warning?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.
No, because the deprecation uses a deprecation code:
Lines 77 to 82 in ce84bac
| if (code !== undefined) { | |
| if (!codesWarned.has(code)) { | |
| process.emitWarning(msg, 'DeprecationWarning', code, deprecated); | |
| codesWarned.add(code); | |
| } | |
| } else { |
| @ExE-Boss Would it be fine for you if we land this PR as is, and then someone else (maybe you?) opens another PR with the changes you're suggesting? I'm afraid I don't have the bandwidth to work on this currently, and I wouldn't want it to miss the v15.x release. |
| @aduh95 I don’t mind either way. |
PR-URL: nodejs#35522 Reviewed-By: Jan Krems <jan.krems@gmail.com> Reviewed-By: Bradley Farias <bradley.meck@gmail.com> Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Ujjwal Sharma <ryzokuken@disroot.org> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
80384e8 to aaf225a Compare | Landed in aaf225a |
module.parentbreaks the ecosystem when read-only (see #32217 (comment)). This PR adds a setter to allow user to change its value instead of throwing.Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes