-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
modules: add setter for module.parent #35522
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -223,13 +223,24 @@ ObjectDefineProperty(Module, 'wrapper', { | |||||||
function getModuleParent() { | ||||||||
return moduleParentCache.get(this); | ||||||||
} | ||||||||
|
||||||||
function setModuleParent(value) { | ||||||||
moduleParentCache.set(this, value); | ||||||||
} | ||||||||
|
||||||||
ObjectDefineProperty(Module.prototype, 'parent', { | ||||||||
get: pendingDeprecation ? deprecate( | ||||||||
getModuleParent, | ||||||||
'module.parent is deprecated due to accuracy issues. Please use ' + | ||||||||
'require.main to find program entry point instead.', | ||||||||
'DEP0144' | ||||||||
) : getModuleParent | ||||||||
) : getModuleParent, | ||||||||
set: pendingDeprecation ? deprecate( | ||||||||
setModuleParent, | ||||||||
'module.parent is deprecated due to accuracy issues. Please use ' + | ||||||||
'require.main to find program entry point instead.', | ||||||||
'DEP0144' | ||||||||
) : setModuleParent, | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make delete work:
Suggested change
|
||||||||
}); | ||||||||
|
||||||||
let debug = require('internal/util/debuglog').debuglog('module', (fn) => { | ||||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,13 @@ | ||||||||||
// Flags: --pending-deprecation | ||||||||||
|
||||||||||
'use strict'; | ||||||||||
const common = require('../common'); | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
||||||||||
common.expectWarning( | ||||||||||
'DeprecationWarning', | ||||||||||
'module.parent is deprecated due to accuracy issues. Please use ' + | ||||||||||
'require.main to find program entry point instead.', | ||||||||||
'DEP0144' | ||||||||||
); | ||||||||||
|
||||||||||
module.parent = undefined; | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
workThere 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?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:
node/lib/internal/util.js
Lines 77 to 82 in ce84bac