Skip to content

Properly deconflict ids of default exports that have been reassigned - #2502

Merged
lukastaegert merged 1 commit into
masterfrom
deconflict-reassigned-default-export-id
Oct 10, 2018
Merged

Properly deconflict ids of default exports that have been reassigned#2502
lukastaegert merged 1 commit into
masterfrom
deconflict-reassigned-default-export-id

Conversation

@lukastaegert

Copy link
Copy Markdown
Member

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

List any relevant issue numbers:
Resolves #2414

Description

See also #2414. The logic for handling default exports of function and class declarations did not properly take into account that those not only declare a local variable as well but that reassigning this local variable will reassign the default export. Cf. these examples:

// the default export will be 42 because it is the value of a that is exported
var a = 42;
export default a;
a = 43;

vs.

// the default export will return 43 because it is the binding of a that is exported
export default function a() {return 42;};
a = () => 43;

Previously, only the first case was handled properly while this PR also handles the second case right. This also cleans up some logic so that almost everything related to default exports with ids is now handled together in ExportDefaultVariable.

@TrySound TrySound left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! Thank you

@TrySound TrySound left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! Thank you

@lukastaegert
lukastaegert merged commit df9ef28 into master Oct 10, 2018
@lukastaegert
lukastaegert deleted the deconflict-reassigned-default-export-id branch October 10, 2018 14:45
@lukastaegert

Copy link
Copy Markdown
Member Author

I put this into 0.66.6 :)

@guybedford

Copy link
Copy Markdown
Contributor

Awesome work!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Babel helper export is wrongly hoisted

3 participants