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 a situation where two different imports with the same name are rendered #2737

Merged

Conversation

lukastaegert
Copy link
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:
Hopefully resolves #2726

Description

This is basically a generalization of #2719. When two different default exports reference the same variable, it is possible that both are rendered as separate imports.

This is just again a fix for the import situation; the exports will still be rendered several times. The problem is that it is only known after tree-shaking if a default export can be identified with the original variable, at which point many other things have already been initialized using the separate variables.

A proper fix for the future might include

  • calculating module dependencies AFTER tree-shaking
  • before doing that
    • replacing default exports in the same module with exports of their original variables
    • removing default exports referencing variables from different modules
    • replacing imports with imports of the original variables (possibly from different modules)

original variable would be rendered as two different imports of a chunk
which have the same name
@lukastaegert lukastaegert force-pushed the gh-2726-different-default-exports-referencing-original branch from bd914af to 962362d Compare March 7, 2019 05:17
@lukastaegert lukastaegert merged commit 858fea4 into master Mar 7, 2019
@lukastaegert lukastaegert deleted the gh-2726-different-default-exports-referencing-original branch March 7, 2019 05:32
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.

Uncaught SyntaxError: Identifier '_$1' has already been declared
1 participant