-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DEWP: Check for magic comments before minification (#65582)
Look for magic wp:polyfill comments before minification. Avoids having to configure Terser to preserve these comments, and also avoids having them in the minified JS. Minifiers run in the processAssets hook at the `PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE` stage. If we hook at the `PROCESS_ASSETS_STAGE_OPTIMIZE_COMPATIBILITY` stage to check for the magic comments, we don't have to worry about configuring Terser to preserve them (and won't have to have them making the output slightly larger either). --------- Co-authored-by: anomiex <[email protected]> Co-authored-by: gziolo <[email protected]> Co-authored-by: sirreal <[email protected]> Co-authored-by: sgomes <[email protected]>
- Loading branch information
1 parent
b08b18b
commit e33271c
Showing
6 changed files
with
101 additions
and
4 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
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
3 changes: 3 additions & 0 deletions
3
...pendency-extraction-webpack-plugin/test/fixtures/polyfill-magic-comment-minified/index.js
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,3 @@ | ||
/* wp:polyfill */ | ||
|
||
// Nothing else, really. |
11 changes: 11 additions & 0 deletions
11
...extraction-webpack-plugin/test/fixtures/polyfill-magic-comment-minified/webpack.config.js
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,11 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
const DependencyExtractionWebpackPlugin = require( '../../..' ); | ||
|
||
module.exports = { | ||
optimization: { | ||
minimize: true, | ||
}, | ||
plugins: [ new DependencyExtractionWebpackPlugin() ], | ||
}; |
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