Skip to content

fix: allow enabling esbuild.minifyWhitespace for es format in lib mode (fix #6555)#18737

Open
WIStudent wants to merge 1 commit intovitejs:mainfrom
WIStudent:fix/minify-whitespace-library-mode-esm
Open

fix: allow enabling esbuild.minifyWhitespace for es format in lib mode (fix #6555)#18737
WIStudent wants to merge 1 commit intovitejs:mainfrom
WIStudent:fix/minify-whitespace-library-mode-esm

Conversation

@WIStudent
Copy link

@WIStudent WIStudent commented Nov 22, 2024

Description

To produce es bundles that can be tree-shaken, lib mode disables minifyWhitespace by default when using the es format. But there are cases where we want an es bundle that is as small as possible and that does not need to be tree-shakable. This change allows esbuild.minifyWhitespace to be re-enabled if the user so desires.

fixes #6555

fix vitejs#6555)

To produce es bundles that can be tree-shaken, lib mode disables
minifyWhitespace by default when using the es format. But there are
cases where we want an es bundle that is as small as possible and that
does not need to be tree-shakable. This change allows minifyWhitespace
to be re-enabled if the user so desires.
@WIStudent WIStudent changed the title fix: Allow enabling esbuild.minifyWhitespace for es format in lib mode (fix #6555) fix: allow enabling esbuild.minifyWhitespace for es format in lib mode (fix #6555) Nov 22, 2024
@WIStudent WIStudent mentioned this pull request Nov 22, 2024
4 tasks
@sapphi-red sapphi-red added the p2-to-be-discussed Enhancement under consideration (priority) label Dec 6, 2024
@eamd-wq eamd-wq mentioned this pull request Dec 26, 2024
7 tasks
@fionamatthews-wk
Copy link

+1 for this. We are building ES modules intended for direct consumption by the browser. Currently, we had to remove lib mode then manually reconfigure a bunch of rollup options back to using what lib mode would already provide us.

Being able to minify whitespaces provides us significant savings in bandwidth across all our projects that use it.

@Tanimodori
Copy link

Tanimodori commented Mar 21, 2025

+1 for this

Workaround:

tsc && vite build && esbuild dist/**/*.js --outdir=dist --allow-overwrite --charset=utf8 --minify-whitespace --format=es

@tkou15
Copy link

tkou15 commented Mar 27, 2025

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

p2-to-be-discussed Enhancement under consideration (priority)

Projects

Status: Later

Development

Successfully merging this pull request may close these issues.

Lib mode format: es.min

5 participants