Describe the bug
unplugin-swc disables esbuild when used in Vite.
esbuild will be automatically disabled if you use this plugin.
On the other hand, SWC minification doesn't work in Vite because it already uses esbuild as its minifier.
Use the minify: true option, it only works for Rollup as Vite uses esbuild to minify the code and cannot be changed.
Therefore, both SWC minification and esbuild minification don't work in Vite. Is this the intended behavior? In my minimal reproduction, I demonstrate two builds: one with the default Vite configuration and another with unplugin-swc. Enabling unplugin-swc completely disables minification. The only solution I found is to use Terser, which works correctly because unplugin-swc doesn't affect it's configuration.
Reproduction
https://github.com/velialiev/vite-swc-minification
System Info
System:
OS: macOS 15.2
CPU: (10) arm64 Apple M1 Pro
Memory: 72.06 MB / 32.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 22.13.1 - ~/.nvm/versions/node/v22.13.1/bin/node
npm: 10.9.2 - ~/.nvm/versions/node/v22.13.1/bin/npm
pnpm: 10.7.0 - ~/Library/pnpm/pnpm
bun: 1.2.8 - ~/.bun/bin/bun
Browsers:
Chrome: 138.0.7204.93
Safari: 18.2
Used Package Manager
pnpm
Validations
Describe the bug
unplugin-swc disables esbuild when used in Vite.
On the other hand, SWC minification doesn't work in Vite because it already uses esbuild as its minifier.
Therefore, both SWC minification and esbuild minification don't work in Vite. Is this the intended behavior? In my minimal reproduction, I demonstrate two builds: one with the default Vite configuration and another with unplugin-swc. Enabling unplugin-swc completely disables minification. The only solution I found is to use Terser, which works correctly because unplugin-swc doesn't affect it's configuration.
Reproduction
https://github.com/velialiev/vite-swc-minification
System Info
System: OS: macOS 15.2 CPU: (10) arm64 Apple M1 Pro Memory: 72.06 MB / 32.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 22.13.1 - ~/.nvm/versions/node/v22.13.1/bin/node npm: 10.9.2 - ~/.nvm/versions/node/v22.13.1/bin/npm pnpm: 10.7.0 - ~/Library/pnpm/pnpm bun: 1.2.8 - ~/.bun/bin/bun Browsers: Chrome: 138.0.7204.93 Safari: 18.2Used Package Manager
pnpm
Validations