To minify a chunk of JavaScript code programatically, it needs to be saved to disk and then passed to Bun.build with minify: true. This isn't ideal, especially when running minification as a transpiler on chunks of JavaScript already in memory, adding unnecessary I/O and bundling logic.
What is the feature you are proposing to solve the problem?
Expose Bun's minification as a function on the API.
const out = Bun.minify(code');
code should ideally accept numerous types, the most obvious being string, ArrayBuffer and FileBlob from Bun.file.
out should be either an ArrayBuffer or string, depending on whatever has the least overhead internally.
What alternatives have you considered?
As the API currently stands, the better alternative is to use a third-party minifier such as Terser, but for simple use-cases it seems antithetical to Bun and what the project is trying to solve in the ecosystem.
What is the problem this feature would solve?
To minify a chunk of JavaScript code programatically, it needs to be saved to disk and then passed to
Bun.build
withminify: true
. This isn't ideal, especially when running minification as a transpiler on chunks of JavaScript already in memory, adding unnecessary I/O and bundling logic.What is the feature you are proposing to solve the problem?
Expose Bun's minification as a function on the API.
code
should ideally accept numerous types, the most obvious beingstring
,ArrayBuffer
andFileBlob
fromBun.file
.out
should be either anArrayBuffer
orstring
, depending on whatever has the least overhead internally.What alternatives have you considered?
As the API currently stands, the better alternative is to use a third-party minifier such as Terser, but for simple use-cases it seems antithetical to Bun and what the project is trying to solve in the ecosystem.