Verifying swc minifier using dbg-swc
Everyone wants a faster build.
But the build time should never be the highest priority.
There are many more important things - namely correctness and user experience.
In this article, I'll describe a way to verify if the SWC minifier is better than the
terser for your web application.
The SWC minifier is fast.
Almost everyone reading this article will know.
Changing the minifier is risky.
Changing here includes updating.
In other words, upgrading the
terser may break your app in production
This was a case for lots of people, including my colleague.
So using the SWC minifier becomes something you want to avoid trying.
And yes, I admit that there are bugs in the SWC minifier that no one knows.
If the SWC minifier makes your bundle larger, it's also a bug because it degrades the user experience. So it's also covered by the new tool.
But there's a way to check if the swc minifier will break your application without breaking the production. Also, You don't need to give me access to the source code. Additionally, you don't need to investigate the bug by yourself.
Today, I'm introducing
dbg-swc, which can be used to verify SWC minifier for your application in a semi-automated way.
How it works
creduce internally, a fantastic CLI tool to reduce an input file to have a minimal input file with the same property.
It repeatedly tries the same operation after modifying the input slightly.
The same operation here is the verification implemented by
Currently, there are two modes.
I'll describe them in the Usage section.
You need to install
creduce to use the reducer.
creduce, please see INSTALL.md
dbg-swc itself, you can download a binary for your platform from https://github.com/swc-project/dbg-swc/releases
After downloading one for your platform, rename it to
dbg-swc, make it executable (
chmod +x dbg-swc), and store it in your
If you want to find an input that the SWC minifier breaks, you can do
dbg-swc es minifier reduce --mode semantics path/to/file_or_dir
Disclaimer: This is not 100% correct verification.
If you want to verify that the SWC minifier does not emit a larger output than terser, you can run
dbg-swc es minifier reduce --mode size path/to/file_or_dir
A single investment can make long-term gains. I'd recommend running it against your application.© DongYoon Kang.RSS