modules: add setter for module.parent#35522
Conversation
|
Review requested:
|
richardlau
left a comment
There was a problem hiding this comment.
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.
Make delete work:
| ) : setModuleParent, | |
| ) : setModuleParent, | |
| configurable: true, |
|
@ExE-Boss making the property configurable should make delete work. |
There was a problem hiding this comment.
| module.parent = undefined; | |
| module.parent = undefined; | |
| delete module.parent; | |
| assert.strictEqual('parent' in module, false); |
There was a problem hiding this comment.
| 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.
moving this to be on the module itself is needed to make delete work
There was a problem hiding this comment.
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.
No, because the deprecation uses a deprecation code:
Lines 77 to 82 in ce84bac
|
@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 <[email protected]> Reviewed-By: Bradley Farias <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Ujjwal Sharma <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
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