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

Prefer locally defined exports and reexports over external namespaces #4064

Merged
merged 3 commits into from May 4, 2021

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:
Resolves #4049

Description

This resolves the scenario in #4049 where you have two competing namespace reexports in a file where the first one reexports the namespace of an external module. When looking for explicit reexports, the logic will first check all namespaces for exports that are not resolved via the external namespace until falling back to that one.

@github-actions
Copy link

github-actions bot commented May 2, 2021

Thank you for your contribution! ❤️

You can try out this pull request locally by installing Rollup via

npm install rollup/rollup#gh-4049-namespace-reexport-issue

or load it into the REPL:
https://rollupjs.org/repl/?pr=4064

@codecov
Copy link

codecov bot commented May 2, 2021

Codecov Report

Merging #4064 (f2cda99) into master (7927f3d) will increase coverage by 0.05%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4064      +/-   ##
==========================================
+ Coverage   97.43%   97.49%   +0.05%     
==========================================
  Files         192      193       +1     
  Lines        6794     6821      +27     
  Branches     1995     2006      +11     
==========================================
+ Hits         6620     6650      +30     
  Misses         84       84              
+ Partials       90       87       -3     
Impacted Files Coverage Δ
src/finalisers/shared/warnOnBuiltins.ts 100.00% <ø> (ø)
cli/run/batchWarnings.ts 99.19% <100.00%> (+0.74%) ⬆️
src/ExternalModule.ts 100.00% <100.00%> (+3.77%) ⬆️
src/Module.ts 100.00% <100.00%> (ø)
src/ast/nodes/MemberExpression.ts 99.16% <100.00%> (-0.02%) ⬇️
src/ast/variables/NamespaceVariable.ts 100.00% <100.00%> (ø)
src/utils/error.ts 100.00% <100.00%> (ø)
src/utils/printStringList.ts 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7927f3d...f2cda99. Read the comment docs.

Copy link
Contributor

@guybedford guybedford left a comment

Choose a reason for hiding this comment

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

This seems great. I wish we had had ambiguous errors for the namespace cases. I guess these could be refined over time possibly, but should likely be avoided anyway.

@lukastaegert lukastaegert force-pushed the gh-4049-namespace-reexport-issue branch from f6d727b to 01a151c Compare May 3, 2021 12:33
@lukastaegert lukastaegert force-pushed the gh-4049-namespace-reexport-issue branch from 01a151c to 3c031cf Compare May 3, 2021 13:09
@guybedford
Copy link
Contributor

Wow, that almost seems like parity and the warning is definitely very useful. Strictly speaking un-errored ambiguous properties are still on the namespace just as undefined values. I've posted a spec PR to explicitly define this in tc39/ecma262#2401.

@guybedford
Copy link
Contributor

Strictly speaking un-errored ambiguous properties are still on the namespace just as undefined values. I've posted a spec PR to explicitly define this in tc39/ecma262#2401.

Turns out they aren't enumerable - should have checked the case more clearly here. So this PR does make RollupJS behaviour fully spec compatible down to the externalization ambiguity that we now have warnings for as well!

@lukastaegert lukastaegert force-pushed the gh-4049-namespace-reexport-issue branch from 33c1254 to f2cda99 Compare May 4, 2021 04:50
@lukastaegert lukastaegert merged commit e249c78 into master May 4, 2021
@lukastaegert lukastaegert deleted the gh-4049-namespace-reexport-issue branch May 4, 2021 05:01
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.

[core] incorrect output of exporting of reference
2 participants