Skip to content

Commit

Permalink
Allow for async minifiers (facebook#754)
Browse files Browse the repository at this point in the history
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: facebook#754

Reviewed By: motiz88

Differential Revision: D33486073

Pulled By: rh389

fbshipit-source-id: 1f6be79741144960803d018d48a51a367665708f
  • Loading branch information
Tyler Rockwood authored and nevilm-lt committed Apr 21, 2022
1 parent 68e3163 commit 9c3800a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/metro-transform-worker/src/index.js
Expand Up @@ -72,7 +72,9 @@ export type MinifierResult = {
...
};

export type Minifier = MinifierOptions => MinifierResult;
export type Minifier = MinifierOptions =>
| MinifierResult
| Promise<MinifierResult>;

export type Type = 'script' | 'module' | 'asset';

Expand Down Expand Up @@ -218,7 +220,7 @@ const minifyCode = async (
const minify = getMinifier(config.minifierPath);

try {
const minified = minify({
const minified = await minify({
code,
map: sourceMap,
filename,
Expand Down

0 comments on commit 9c3800a

Please sign in to comment.