-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Babel Preset Default: Add polyfill for WordPress built from core-js (#…
…31279) * Babel Preset Default: Add polyfill for WordPress built from core-js * Address feedback from code review
- Loading branch information
1 parent
51adf3d
commit 6499d70
Showing
8 changed files
with
165 additions
and
252 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/env node | ||
|
||
/** | ||
* External dependencies | ||
*/ | ||
const builder = require( 'core-js-builder' ); | ||
const { minify } = require( 'uglify-js' ); | ||
const { writeFile } = require( 'fs' ).promises; | ||
|
||
builder( { | ||
modules: [ 'es', 'web' ], | ||
// core-js is extremely conservative in which polyfills to include. | ||
// Knowing about tiny browser implementation bugs that anyone rarely cares about, | ||
// we prevent some features from having the full polyfill included. | ||
// @see https://github.com/WordPress/gutenberg/pull/31279 | ||
exclude: [ 'es.promise' ], | ||
targets: require( '@wordpress/browserslist-config' ), | ||
filename: './build/polyfill.js', | ||
} ) | ||
.then( async ( code ) => { | ||
const output = minify( code, { | ||
output: { | ||
comments: ( node, comment ) => | ||
comment.value.indexOf( 'License' ) >= 0, | ||
}, | ||
} ); | ||
await writeFile( './build/polyfill.min.js', output.code ); | ||
} ) | ||
.catch( ( error ) => { | ||
// eslint-disable-next-line no-console | ||
console.log( error ); | ||
process.exit( 1 ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters