Skip to content

Commit

Permalink
Switch default JS minifier to metro-minify-terser internally
Browse files Browse the repository at this point in the history
Summary:
Align internal Metro configuration of `minifierPath` with the OSS default, and away from the deprecated `uglify-es`.

This also allows us to remove some hacks necessary to test `uglify-es`, because it uses `fs` to load its dependencies.

Reviewed By: motiz88

Differential Revision: D43391760

fbshipit-source-id: 0c91b82bdb8e8b0054051a6d4ca40f440a8516f8
  • Loading branch information
robhogan authored and facebook-github-bot committed Feb 27, 2023
1 parent 3bef954 commit b422ed6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/metro-source-map/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"devDependencies": {
"@babel/core": "^7.20.0",
"@babel/parser": "^7.20.0",
"uglify-es": "^3.1.9"
"terser": "^5.15.0"
},
"engines": {
"node": ">=16"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const fs = require('fs');
const invariant = require('invariant');
const {add0, add1} = require('ob1');
const path = require('path');
const uglifyEs = require('uglify-es');
const terser = require('terser');

/* eslint-disable no-multi-str */

Expand Down Expand Up @@ -83,9 +83,9 @@ describe('composeSourceMaps', () => {
}
});

it('verifies merged source maps work the same as applying them separately', () => {
it('verifies merged source maps work the same as applying them separately', async () => {
// Apply two tranformations: compression, then mangling.
const stage1 = uglifyEs.minify(
const stage1 = await terser.minify(
{'test1.js': TestScript1, 'test2.js': TestScript2},
{
compress: true,
Expand All @@ -98,7 +98,7 @@ describe('composeSourceMaps', () => {
'Minification error in stage1',
);
const {code: code1, map: map1} = stage1;
const stage2 = uglifyEs.minify(
const stage2 = await terser.minify(
{'intermediate.js': code1},
{compress: true, mangle: true, sourceMap: true},
);
Expand Down

0 comments on commit b422ed6

Please sign in to comment.