1
0
mirror of https://github.com/lancedikson/bowser synced 2026-09-22 12:05:23 +00:00

fix(build): fail loudly when terser produces no output for a chunk

This commit is contained in:
naorpeled
2026-08-29 23:50:17 +03:00
parent 19c2d8d3a1
commit 434016a1f9

View File

@@ -46,7 +46,7 @@ const legacyBabel = (useBuiltIns: false | 'entry') => babel({
*/
const terser = () => ({
name: 'bowser:terser',
async renderChunk(code: string) {
async renderChunk(code: string, chunk: { fileName: string }) {
const result = await minify(code, {
ecma: 5,
// IE 8: reserved words as property names must stay quoted.
@@ -57,7 +57,10 @@ const terser = () => ({
comments: /^!/,
},
});
return { code: result.code as string };
if (typeof result.code !== 'string') {
throw new Error(`terser produced no output for ${chunk.fileName}`);
}
return { code: result.code };
},
});