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

Bun.build preserve important comments #9795

Open
ElYaiko opened this issue Apr 1, 2024 · 5 comments
Open

Bun.build preserve important comments #9795

ElYaiko opened this issue Apr 1, 2024 · 5 comments
Labels
bundler Something to do with the bundler enhancement New feature or request

Comments

@ElYaiko
Copy link

ElYaiko commented Apr 1, 2024

What is the problem this feature would solve?

Preserving important comments like licenses when using Bun.build

What is the feature you are proposing to solve the problem?

Adding a flag so comments starting with /**! will be preserved.

What alternatives have you considered?

https://esbuild.github.io/api/#legal-comments

@ElYaiko ElYaiko added the enhancement New feature or request label Apr 1, 2024
@TomasHubelbauer
Copy link

IMO having an option for preserving all comments would also be beneficial. Function.toString() will display internal comments so removing them is kind of a breaking change as it changes the result of the toString and while this doesn't affect a lot of people, with preserved comments you can do some nifty things so it would be nice to have that option.

@busybox11
Copy link

This feature could be really useful to me as a userscript developer.
Every userscript has to begin with a // ==UserScript== section, ending by // ==/UserScript==. I'm trying to move my Vanilla JS scripts to TS projects, by running Bun.build as a build step. This could really be beneficial for me as well.

@RiskyMH RiskyMH added the bundler Something to do with the bundler label Oct 13, 2024
@RiskyMH
Copy link
Contributor

RiskyMH commented Oct 13, 2024

It's interesting that bun build preserves //! comments but not /*! like esbuild. @paperdave, would it make sense for Bun to handle this for consistency, or maybe introduce a flag to control comment preservation like esbuild does for legal comments?

@paperdave
Copy link
Member

Yes. See #8727 (this issue is kind of a duplicate of that but theres some new ideas here so i think we can leave it open)

I think in addition to //! it would be nice to support // ==UserScript== as well, but an alternative to that would be using the newly added --banner option (available on canary right now, and in the next release).

IMO having an option for preserving all comments would also be beneficial.

Ideally, build without --minify-whitespace could do that. I don't know how hard it would be to add.

@guest271314

This comment was marked as off-topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bundler Something to do with the bundler enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants