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(findExports): correctly dedup named exports #86

Merged
merged 5 commits into from Sep 20, 2022
Merged

Conversation

antfu
Copy link
Member

@antfu antfu commented Sep 20, 2022

// Prevent multiple exports of same function, only keep latest iteration of signatures
const nextExport = exports[index + 1]
Copy link
Member Author

Choose a reason for hiding this comment

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

We were dedupe with the one that filtered out by AST. Changed to two passes of .filter to ensure exports is the real exports we want for dedupe.

@codecov
Copy link

codecov bot commented Sep 20, 2022

Codecov Report

Merging #86 (fbf5c41) into main (62f56fe) will increase coverage by 0.07%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main      nuxt/framework#86      +/-   ##
==========================================
+ Coverage   67.48%   67.56%   +0.07%     
==========================================
  Files          13       13              
  Lines        2196     2201       +5     
  Branches      233      233              
==========================================
+ Hits         1482     1487       +5     
  Misses        695      695              
  Partials       19       19              
Impacted Files Coverage Δ
src/analyze.ts 97.68% <100.00%> (+0.05%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

src/analyze.ts Outdated
return exportsLocation.some(location => exp.start <= location.start && exp.end >= location.end)
return exportsLocation.some(location =>
(exp.start <= location.start && location.start <= exp.end) ||
(exp.start <= location.end && location.end <= exp.end)
Copy link
Member

@pi0 pi0 Sep 20, 2022

Choose a reason for hiding this comment

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

Previous condition (token within match) seems keep tests pass. Why we need to change it to (token start within match || token end within match)?

Copy link
Member

Choose a reason for hiding this comment

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

Made it into a comment to marge fix asap. fbf5c41. Would be happy to discuss more and change checking strategy if you think there is a case needs this check.

Copy link
Member Author

Choose a reason for hiding this comment

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

That was my initial assumption of the cause - yes I think we don't need to change it for this case.

@pi0 pi0 changed the title fix(findExports): correctly filter out exports fix(findExports): correctly dedup named exports Sep 20, 2022
@pi0 pi0 merged commit 6b5df10 into main Sep 20, 2022
@pi0 pi0 deleted the fix/with-without-comment branch September 20, 2022 07:58
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.

Auto-import (composable) breaks when comments contain export default function
2 participants