Skip to content
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

Merged
merged 3 commits into from Jan 29, 2021

Conversation

chmelevskij
Copy link
Contributor

@chmelevskij chmelevskij commented Jan 10, 2021

Rollup Plugin Name: commonjs

This PR contains:

  • bugfix
  • feature
  • refactor
  • documentation
  • other

Are tests included?

  • yes (bugfixes and features will not be merged without tests)
  • no

Breaking Changes?

  • yes (breaking changes will not be merged unless absolutely necessary)
  • no

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.

Copy link
Member

@tjenkinson tjenkinson left a 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.

@@ -115,3 +115,7 @@ export function isLocallyShadowed(name, scope) {
}
return false;
}

export function isShorthandProperty(parent) {
return parent && parent.shorthand;
Copy link
Member

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?

Copy link
Member

@lukastaegert lukastaegert left a 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.

Copy link
Member

@lukastaegert lukastaegert left a 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.

@tjenkinson
Copy link
Member

tjenkinson commented Jan 20, 2021

I might not cause issues now, but who knows about the future.

IMO this still applies and not checking the type feels similar to leaving a dependency version as *. You can add new support in a controlled way in a non-major version but accidental new features from a parser upgrade (which may be present for some users and not others due to npm and semver rules) become a bit more fuzzy.

I'm assuming a new type in the parser wouldn't need to be major

@shellscape
Copy link
Collaborator

@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?

@lukastaegert
Copy link
Member

With the last changes, I think consensus is to merge this.

@shellscape
Copy link
Collaborator

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants