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

Keep leading comments on consecutive lines #4975

Merged
merged 1 commit into from May 5, 2023

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:

Description

Previously, only comments on the first line of a module were guaranteed to be included while subsequent comments were only retained if the first statement remained part of the bundle. This was a problem when leadings comments were written as a series of line comments instead of a block comment, or there was more than one comment.
This PR changes the logic so that all leadings comments are retained provided that

  • there are no empty lines in between
  • each line that is not already part of a comment starts with a comment

@vercel
Copy link

vercel bot commented May 4, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
rollup ✅ Ready (Inspect) Visit Preview May 4, 2023 8:48am

@github-actions
Copy link

github-actions bot commented May 4, 2023

Thank you for your contribution! ❤️

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

npm install rollup/rollup#keep-leading-comments

or load it into the REPL:
https://rollup-ddyaxu9h1-rollup-js.vercel.app/repl/?pr=4975

@codecov
Copy link

codecov bot commented May 4, 2023

Codecov Report

Merging #4975 (6cbe719) into master (fd64748) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master    #4975   +/-   ##
=======================================
  Coverage   98.99%   98.99%           
=======================================
  Files         222      222           
  Lines        8123     8128    +5     
  Branches     2237     2239    +2     
=======================================
+ Hits         8041     8046    +5     
  Misses         28       28           
  Partials       54       54           
Impacted Files Coverage Δ
src/utils/renderHelpers.ts 100.00% <ø> (ø)
src/ast/nodes/Program.ts 100.00% <100.00%> (ø)

@lukastaegert lukastaegert merged commit f85634c into master May 5, 2023
12 checks passed
@lukastaegert lukastaegert deleted the keep-leading-comments branch May 5, 2023 04:17
@rollup-bot
Copy link
Collaborator

This PR has been released as part of rollup@3.21.5. You can test it via npm install rollup.

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.

only the first line of comments before import statement is preserved
2 participants