-
-
Notifications
You must be signed in to change notification settings - Fork 597
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
fix(commonjs): correctly replace shorthand require
#764
fix(commonjs): correctly replace shorthand require
#764
Conversation
0afb9fe
to
4b83f0b
Compare
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.
Thanks. Not super familiar with this plugin so think it still needs a review from someone else, but the change makes sense. I think we should check the type
on the parent node too though.
packages/commonjs/src/ast-utils.js
Outdated
@@ -115,3 +115,7 @@ export function isLocallyShadowed(name, scope) { | |||
} | |||
return false; | |||
} | |||
|
|||
export function isShorthandProperty(parent) { | |||
return parent && parent.shorthand; |
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.
Please can you check parent.type
is the correct value too?
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.
Looks good, but agree with @tjenkinson 's comment. I might not cause issues now, but who knows about the future.
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.
Actually, searching through the entire https://github.com/estree/estree/search?q=shorthand there is only one potential upcoming use-case for shorthand, which would be RecordProperty
, and it seems to me that those would benefit from the same treatment as regular Property
. So from my side, we do not necessarily need this right now.
IMO this still applies and not checking the type feels similar to leaving a dependency version as I'm assuming a new type in the parser wouldn't need to be major |
@lukastaegert @tjenkinson is the consensus that this isn't needed at the moment, or that it's useful and we should merge but keep an eye out for potential issues in the future? |
With the last changes, I think consensus is to merge this. |
Rollup Plugin Name:
commonjs
This PR contains:
Are tests included?
Breaking Changes?
If yes, then include "BREAKING CHANGES:" in the first commit message body, followed by a description of what is breaking.
List any relevant issue numbers: #763
Description
Checks that
require
is shorthand property.