From 6b95928efa51dd9b122df0d77ddfef95aeeea13f Mon Sep 17 00:00:00 2001 From: Connor Clark Date: Thu, 16 Sep 2021 17:28:56 -0500 Subject: [PATCH] misc(build): fix minifyFileTransform stream bug in Node 16 (#13073) --- build/build-utils.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/build/build-utils.js b/build/build-utils.js index 64d633d0f920..358172f063cf 100644 --- a/build/build-utils.js +++ b/build/build-utils.js @@ -31,10 +31,9 @@ function minifyFileTransform(file) { code += chunk.toString(); next(); }, - async final(next) { - try { - const result = await terser.minify(code, {ecma: 2019}); - + // TODO: when min is Node 16, can just make this function async. + final(next) { + terser.minify(code, {ecma: 2019}).then(result => { if (result.code) { const saved = code.length - result.code.length; // eslint-disable-next-line no-console @@ -43,11 +42,11 @@ function minifyFileTransform(file) { } next(); - } catch (err) { + }).catch(err => { // eslint-disable-next-line no-console console.error(err); process.exit(1); - } + }); }, }); }