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

refactor: some code and type fixes #4413

Merged
merged 30 commits into from Feb 23, 2022
Merged

Conversation

dnalborczyk
Copy link
Contributor

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:

Description

@codecov
Copy link

codecov bot commented Feb 19, 2022

Codecov Report

Merging #4413 (5b0c7a8) into master (51cab92) will decrease coverage by 0.00%.
The diff coverage is 97.91%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4413      +/-   ##
==========================================
- Coverage   98.75%   98.75%   -0.01%     
==========================================
  Files         204      204              
  Lines        7322     7299      -23     
  Branches     2079     2078       -1     
==========================================
- Hits         7231     7208      -23     
  Misses         33       33              
  Partials       58       58              
Impacted Files Coverage Δ
cli/run/timings.ts 0.00% <0.00%> (ø)
src/utils/PluginDriver.ts 100.00% <ø> (ø)
cli/run/batchWarnings.ts 99.18% <100.00%> (-0.02%) ⬇️
cli/run/index.ts 100.00% <100.00%> (ø)
src/Bundle.ts 100.00% <100.00%> (ø)
src/Chunk.ts 100.00% <100.00%> (ø)
src/Module.ts 100.00% <100.00%> (ø)
src/ModuleLoader.ts 100.00% <100.00%> (ø)
src/ast/nodes/MetaProperty.ts 100.00% <100.00%> (ø)
src/ast/values.ts 100.00% <100.00%> (ø)
... and 9 more

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 51cab92...5b0c7a8. Read the comment docs.

@dnalborczyk dnalborczyk marked this pull request as draft February 19, 2022 22:05
@dnalborczyk dnalborczyk force-pushed the some-fixes branch 2 times, most recently from 0454980 to 4be1a20 Compare February 20, 2022 05:07
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.

Seems fine to me, with comments, some small mistakes here to be careful about.

src/Chunk.ts Outdated
})
module.chunkNames
.filter(({ isUserDefined }) => isUserDefined)
.map(({ name }) => ({ name }))
Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't the same as it won't do name string deduping in the set.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

great catch, thank you! too bad this wasn't caught by a test 😞 I reverted and added a comment.

Copy link
Member

Choose a reason for hiding this comment

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

Actually I think it does not change anything at the moment, which is why there is no test. The only situation where you have entries here is if the user used an object as entry point. In that case, the name properties are the keys of that object, and object keys deduplicate themselves. It does not hurt either, though.

specifier,
module.id
));
return (module.resolvedIds[specifier] ??= this.handleResolveId(
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we using ?? in the codebase now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, nullish coalescing is used throughout the codebase, logical nullish assignment a little bit.

down-leveling only adds a tiny amount of additional code which results in almost the same amount without the change. if v3 were about to support node.js v14+ nullish coalescing would also run native as well. short circuiting should also make logical nullish assignment faster.

the correct syntax mapping would have been ||= rather, but I thought since ResolveId is an object, ??= would fit better to show the intend of only assigning when null or undefined.

src/utils/FileEmitter.ts Outdated Show resolved Hide resolved
@dnalborczyk dnalborczyk force-pushed the some-fixes branch 2 times, most recently from a9ae872 to 847fc1a Compare February 23, 2022 03:51
@dnalborczyk dnalborczyk marked this pull request as ready for review February 23, 2022 04:38
@lukastaegert lukastaegert merged commit 275dc2f into rollup:master Feb 23, 2022
@dnalborczyk dnalborczyk deleted the some-fixes branch February 25, 2022 04:22
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.

None yet

3 participants