oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
73.22k stars 2.69k forks source link

bundler: implement `--legal-comments` to control how licenses in source code is bundled. #8727

Open muuvmuuv opened 7 months ago

muuvmuuv commented 7 months ago

What is the problem this feature would solve?

To minify the bundle (w/o --compile) it would be great to have the licence exported to another file or to be removed completely. Also some JS is still unminified.

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

Minify compiled bundle more.

What alternatives have you considered?

Manually sed it out or with esbuild like explained below.

Electroid commented 7 months ago

Out of curiosity, is this something you can do in esbuild?

muuvmuuv commented 7 months ago

Valid point. Yes. Still it would have comments left, and some JS is not minified but just by using --compile.

bun esbuild src/main.ts --bundle --outfile=server-minified --platform=node --format=esm --minify --legal-comments=none
bun bun ./server-minified --compile --outfile=server

image

paperdave commented 7 months ago

many places in the current code have markers for this.

image

most of the work for this would be to just copy esbuild's implementation and port into zig