-
Notifications
You must be signed in to change notification settings - Fork 384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove empty scripts after webpack compilation #6780
Conversation
So far, a custom `IgnoreExtraneousStyleAssets` webpack plugin has been used to prevent generation of empty JS files (e.g. when CSS has been an entry point). After updating webpack from version 4 to 5, the custom plugin stopped working due to webpack internal API changes. It turns out there is a third-party plugin, `webpack-remove-empty-scripts` that does exactly what we need. It should be run before `DependencyExtractionWebpackPlugin` so that the empty JS files are removed before empty `.asset.php` files are created.
Plugin builds for 99a3a89 are ready 🛎️!
|
Here's a comparison before/after: The empty files are all getting deleted as expected, except there's one interesting thing: Clicking the “Edit” link for enabling AMP does nothing. Why was this file empty before? Checking the same page with the changes in this PR shows shows no errors and the toggle is working: This file was not empty in 2.1.4, so something broke in |
Changes to All that looks right. Changes to This looks similarly right, except for the Or maybe not? Is it being generated for amp-wp/src/Admin/Polyfills.php Lines 164 to 177 in 5ab4412
But if that is the case, then why is the These are the changes to the |
I think it is the case. This file should not be generated since So far,
I guess we can use the hard-coded value and update it anytime the |
Good idea. I've done that in 99a3a89. |
Perfect! |
Summary
Fixes #6778
So far, a custom
IgnoreExtraneousStyleAssets
webpack plugin has been used to prevent generation of empty JS files (e.g. when CSS has been an entry point). After updating webpack from version 4 to 5, the custom plugin stopped working due to webpack internal API changes.It turns out there is a third-party plugin,
webpack-remove-empty-scripts
that does exactly what we need. It should be run beforeDependencyExtractionWebpackPlugin
so that empty JS files are removed before.asset.php
files are created.Checklist