From 9c3800a92936d4b5b92a753a95a6975b1a4d0c0d Mon Sep 17 00:00:00 2001 From: Tyler Rockwood Date: Wed, 19 Jan 2022 05:11:30 -0800 Subject: [PATCH] Allow for async minifiers (#754) Summary: **Summary** Terser v5 is async, so if we want to upgrade to support the latest syntax we need this. **Test plan** Existing unit tests - this only adds an await clause, which is safe to do to non-promises, so it shouldn't break anything. Pull Request resolved: https://github.com/facebook/metro/pull/754 Reviewed By: motiz88 Differential Revision: D33486073 Pulled By: rh389 fbshipit-source-id: 1f6be79741144960803d018d48a51a367665708f --- packages/metro-transform-worker/src/index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/metro-transform-worker/src/index.js b/packages/metro-transform-worker/src/index.js index 7977ca5a4f..329952719a 100644 --- a/packages/metro-transform-worker/src/index.js +++ b/packages/metro-transform-worker/src/index.js @@ -72,7 +72,9 @@ export type MinifierResult = { ... }; -export type Minifier = MinifierOptions => MinifierResult; +export type Minifier = MinifierOptions => + | MinifierResult + | Promise; export type Type = 'script' | 'module' | 'asset'; @@ -218,7 +220,7 @@ const minifyCode = async ( const minify = getMinifier(config.minifierPath); try { - const minified = minify({ + const minified = await minify({ code, map: sourceMap, filename,