Skip to content

fix(findExports): correctly dedup named exports#86

Merged
pi0 merged 5 commits into
mainfrom
fix/with-without-comment
Sep 20, 2022
Merged

fix(findExports): correctly dedup named exports#86
pi0 merged 5 commits into
mainfrom
fix/with-without-comment

Conversation

@antfu

@antfu antfu commented Sep 20, 2022

Copy link
Copy Markdown
Member

Comment thread src/analyze.ts
}
.filter(exp => !exportLocations || _isExportStatement(exportLocations, exp))
// Prevent multiple exports of same function, only keep latest iteration of signatures
const nextExport = exports[index + 1]

Copy link
Copy Markdown
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

codecov Bot commented Sep 20, 2022

Copy link
Copy Markdown

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.

Comment thread 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)

@pi0 pi0 Sep 20, 2022

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.

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
Copy Markdown
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
Copy Markdown
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