Skip to content

Commit

Permalink
Switch from UglifyJS to Terser to build the polyfill script (#65278)
Browse files Browse the repository at this point in the history
Co-authored-by: jsnajdr <jsnajdr@git.wordpress.org>
Co-authored-by: tyxla <tyxla@git.wordpress.org>
Co-authored-by: sgomes <sergiomdgomes@git.wordpress.org>
  • Loading branch information
4 people authored Sep 12, 2024
1 parent 33bdcbc commit 3368298
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
19 changes: 10 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,9 @@
"storybook-source-link": "2.0.9",
"strip-json-comments": "5.0.0",
"style-loader": "3.2.1",
"terser": "5.32.0",
"terser-webpack-plugin": "5.3.9",
"typescript": "5.5.3",
"uglify-js": "3.13.7",
"uuid": "9.0.1",
"webdriverio": "8.16.20",
"webpack": "5.88.2",
Expand Down
14 changes: 7 additions & 7 deletions packages/babel-preset-default/bin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* External dependencies
*/
const builder = require( 'core-js-builder' );
const { minify } = require( 'uglify-js' );
const { minify } = require( 'terser' );
const { writeFile } = require( 'fs' ).promises;

builder( {
Expand All @@ -18,15 +18,15 @@ builder( {
targets: require( '@wordpress/browserslist-config' ),
filename: './build/polyfill.js',
} )
.then( async ( code ) => {
const output = minify( code, {
.then( ( code ) =>
minify( code, {
output: {
comments: ( node, comment ) =>
comment.value.indexOf( 'License' ) >= 0,
comment.value.toLowerCase().includes( 'license' ),
},
} );
await writeFile( './build/polyfill.min.js', output.code );
} )
} )
)
.then( ( output ) => writeFile( './build/polyfill.min.js', output.code ) )
.catch( ( error ) => {
// eslint-disable-next-line no-console
console.log( error );
Expand Down

0 comments on commit 3368298

Please sign in to comment.