Exclude dev files from plugin production builds: source files, changelogs, dev configs, docs#47365
Exclude dev files from plugin production builds: source files, changelogs, dev configs, docs#47365
Conversation
…duction Broadens the production-exclude rules in .gitattributes to catch all TypeScript and SCSS source files under jetpack_vendor/ and vendor/. The previous SCSS rules only matched src/css/*.scss, missing files in other paths (15 SCSS files leaking). There were no TypeScript rules at all for vendor packages (225 .ts/.tsx files leaking). Fixes MONOREP-371
…uction builds Add production-exclude rules for TypeScript and SCSS source files under jetpack_vendor/automattic/ and vendor/automattic/ to every plugin's .gitattributes. These are build inputs with compiled output already shipping — they're not needed at runtime. For wpcomsh, also broadens the existing narrow SCSS rules from **/src/css/*.scss to **/*.scss to catch files in other paths. Also updates the plugin skeleton template so new plugins get these rules from the start.
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! Beta plugin: No scheduled milestone found for this plugin. If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Jetpack plugin: The Jetpack plugin has different release cadences depending on the platform:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Backup plugin: No scheduled milestone found for this plugin. If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Vaultpress plugin: No scheduled milestone found for this plugin. If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Boost plugin: No scheduled milestone found for this plugin. If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Search plugin: No scheduled milestone found for this plugin. If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Social plugin: No scheduled milestone found for this plugin. If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Starter Plugin plugin: No scheduled milestone found for this plugin. If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Protect plugin: No scheduled milestone found for this plugin. If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Videopress plugin: No scheduled milestone found for this plugin. If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Super Cache plugin: No scheduled milestone found for this plugin. If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Mu Wpcom plugin:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Inspect plugin: No scheduled milestone found for this plugin. If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Wpcomsh plugin:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Automattic For agencies client plugin: No scheduled milestone found for this plugin. If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Classic Theme helper plugin plugin: No scheduled milestone found for this plugin. If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Paypal Payment buttons plugin: No scheduled milestone found for this plugin. If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Wpcloud Sso plugin: No scheduled milestone found for this plugin. If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
|
Note: I haven't actually tested to make sure none of the plugins are expecting SCSS or TS files to exist. |
There was a problem hiding this comment.
Pull request overview
Updates plugin .gitattributes rules so production mirror builds no longer ship vendor TypeScript/TSX and SCSS source files, reducing distribution size for mirrored plugins (Fixes MONOREP-371).
Changes:
- Broaden SCSS exclusions in vendor directories to exclude all
*.scssunderjetpack_vendor/automattic/andvendor/automattic/. - Add exclusions for
*.tsand*.tsxunderjetpack_vendor/automattic/andvendor/automattic/across affected plugins. - Update the plugin skeleton template so new plugins get these production-exclude rules by default, and add changelog entries for affected plugins.
Reviewed changes
Copilot reviewed 39 out of 39 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tools/cli/skeletons/plugins/.gitattributes | Adds default production-exclude patterns for vendor *.scss, *.ts, and *.tsx in new plugin skeletons. |
| projects/plugins/wpcomsh/.gitattributes | Expands vendor SCSS exclusion and adds vendor TS/TSX exclusions. |
| projects/plugins/wpcomsh/changelog/exclude-dev-vendor-files | Changelog entry for excluding vendor TS/TSX/SCSS from production builds. |
| projects/plugins/wpcloud-sso/.gitattributes | Adds vendor SCSS/TS/TSX production exclusions. |
| projects/plugins/wpcloud-sso/changelog/exclude-dev-vendor-files | Changelog entry for excluding vendor TS/TSX/SCSS from production builds. |
| projects/plugins/videopress/.gitattributes | Adds vendor SCSS/TS/TSX production exclusions. |
| projects/plugins/videopress/changelog/exclude-dev-vendor-files | Changelog entry for excluding vendor TS/TSX/SCSS from production builds. |
| projects/plugins/vaultpress/.gitattributes | Adds vendor SCSS/TS/TSX production exclusions. |
| projects/plugins/vaultpress/changelog/exclude-dev-vendor-files | Changelog entry for excluding vendor TS/TSX/SCSS from production builds. |
| projects/plugins/super-cache/.gitattributes | Adds vendor SCSS/TS/TSX production exclusions. |
| projects/plugins/super-cache/changelog/exclude-dev-vendor-files | Changelog entry for excluding vendor TS/TSX/SCSS from production builds. |
| projects/plugins/starter-plugin/.gitattributes | Adds vendor SCSS/TS/TSX production exclusions. |
| projects/plugins/starter-plugin/changelog/exclude-dev-vendor-files | Changelog entry for excluding vendor TS/TSX/SCSS from production builds. |
| projects/plugins/social/.gitattributes | Adds vendor SCSS/TS/TSX production exclusions. |
| projects/plugins/social/changelog/exclude-dev-vendor-files | Changelog entry for excluding vendor TS/TSX/SCSS from production builds. |
| projects/plugins/search/.gitattributes | Adds vendor SCSS/TS/TSX production exclusions. |
| projects/plugins/search/changelog/exclude-dev-vendor-files | Changelog entry for excluding vendor TS/TSX/SCSS from production builds. |
| projects/plugins/protect/.gitattributes | Adds vendor SCSS/TS/TSX production exclusions. |
| projects/plugins/protect/changelog/exclude-dev-vendor-files | Changelog entry for excluding vendor TS/TSX/SCSS from production builds. |
| projects/plugins/paypal-payment-buttons/.gitattributes | Adds vendor SCSS/TS/TSX production exclusions. |
| projects/plugins/paypal-payment-buttons/changelog/exclude-dev-vendor-files | Changelog entry for excluding vendor TS/TSX/SCSS from production builds. |
| projects/plugins/mu-wpcom-plugin/.gitattributes | Adds vendor SCSS/TS/TSX production exclusions. |
| projects/plugins/mu-wpcom-plugin/changelog/exclude-dev-vendor-files | Changelog entry for excluding vendor TS/TSX/SCSS from production builds. |
| projects/plugins/jetpack/.gitattributes | Expands vendor SCSS exclusion and adds vendor TS/TSX exclusions. |
| projects/plugins/jetpack/changelog/exclude-dev-files-from-production | Jetpack changelog entry for excluding vendor TypeScript and SCSS sources in production builds. |
| projects/plugins/inspect/.gitattributes | Adds vendor SCSS/TS/TSX production exclusions. |
| projects/plugins/inspect/changelog/exclude-dev-vendor-files | Changelog entry for excluding vendor TS/TSX/SCSS from production builds. |
| projects/plugins/crm/.gitattributes | Adds vendor SCSS/TS/TSX production exclusions. |
| projects/plugins/crm/changelog/exclude-dev-vendor-files | Changelog entry for excluding vendor TS/TSX/SCSS from production builds. |
| projects/plugins/classic-theme-helper-plugin/.gitattributes | Adds vendor SCSS/TS/TSX production exclusions. |
| projects/plugins/classic-theme-helper-plugin/changelog/exclude-dev-vendor-files | Changelog entry for excluding vendor TS/TSX/SCSS from production builds. |
| projects/plugins/boost/.gitattributes | Adds vendor SCSS/TS/TSX production exclusions. |
| projects/plugins/boost/changelog/exclude-dev-vendor-files | Changelog entry for excluding vendor TS/TSX/SCSS from production builds. |
| projects/plugins/beta/.gitattributes | Adds vendor SCSS/TS/TSX production exclusions. |
| projects/plugins/beta/changelog/exclude-dev-vendor-files | Changelog entry for excluding vendor TS/TSX/SCSS from production builds. |
| projects/plugins/backup/.gitattributes | Adds vendor SCSS/TS/TSX production exclusions. |
| projects/plugins/backup/changelog/exclude-dev-vendor-files | Changelog entry for excluding vendor TS/TSX/SCSS from production builds. |
| projects/plugins/automattic-for-agencies-client/.gitattributes | Adds vendor SCSS/TS/TSX production exclusions. |
| projects/plugins/automattic-for-agencies-client/changelog/exclude-dev-vendor-files | Changelog entry for excluding vendor TS/TSX/SCSS from production builds. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Code Coverage SummaryThis PR did not change code coverage! That could be good or bad, depending on the situation. Everything covered before, and still is? Great! Nothing was covered before? Not so great. 🤷 |
Adds production-exclude rules for .jsx files alongside the existing .ts, .tsx, and .scss rules. 25 JSX source files were leaking into jetpack-production (mostly forms block icons and connection components).
|
Some were previously excluded, but not all. Updated in abe92da. |
…ngelogs, licenses, configs Extends the production-exclude rules to cover more development-only files that ship in vendor packages but provide zero runtime value: - Source maps (*.map) -- 2.1M in jetpack-forms alone - CHANGELOG.md files (53 files, 1.9M total) - LICENSE.txt, SECURITY.md, TRACKING.md (1.3M) - docs/ directories, dev configs (.babelrc, babel.config.*, webpack/jest configs) - .gitignore, package.json, test/ directories in vendor packages - Jetpack-specific: root CHANGELOG.md, SECURITY.md, vendor/composer metadata Total estimated savings: ~5.8M across all plugins.
anomiex
left a comment
There was a problem hiding this comment.
Rather than having the plugins exclude various files from under vendor/, I think we'd do better to fix our packages' .gitattributes to have them not contain those files in the first place. That goes for the existing .../src/css/*.scss as well.
The existing exclusions for vendor/**/composer.json are a different thing, Composer needs those but we don't so much.
The existing vendor/**/README.md exclusions I could go either way on; possibly we should have the packages flag them as export-ignore so they don't get included in vendor/ directories, or possibly it's useful for other users of the packages to have the file available there instead of them having to go online. 🤷
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 39 out of 39 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
I see you just added more types of files.
Ideally we'd include minified JS along with source maps everywhere, as that makes for a good debugging experience and would work more reliably for translate.wordpress.org i18n than what we have to do now to get it working with just the minified JS. But you're right, they take up a bunch of disk space. I wish browsers would be able to use compressed map files, but I don't think any do.
My feelings on these are similar to the README.md files. For our packages we're probably safe to exclude
Dev configs should probably be
Fix these too.
I'm pretty sure we want the root CHANGELOG.md and SECURITY.md, for people to be able to find. vendor/composer metadata we'll have to be careful about excluding, to make sure it doesn't break the autoloader. |
And for Forms in particular, note they're experimenting with wp-build, which probably doesn't do all the stuff to make sure translate.wordpress.org i18n keeps working without the source maps. |
Regarding |
…view Remove *.map, root CHANGELOG.md/SECURITY.md, and third-party LICENSE exclusions added in 26c3319. Source maps are valuable for debugging and i18n; root docs should stay for discoverability; third-party license files must be preserved.
|
Fair enough on those — restored source maps, root CHANGELOG.md/SECURITY.md, and third-party license files. We can talk about source maps as a separate discussion since there are good arguments on both sides there (debugging/i18n value vs disk savings). The rest of the expanded exclusions (dev configs, vendor subpackage changelogs/licenses for automattic/** only, test dirs, docs, etc.) stay as-is (and seem acceptable to everyone) |
|
On what our packages do, I think that would be a good thing to dig into. I can see different arguments that might exist between different consumers' expectations. I'm okay seeing the plugin-level check as a "we're the final packagers of this code meant for end-users directly so we can be strict" and if we can make improvements to the individual packages, great... this particular PR's attribute changes wouldn't matter that much if/when that happens. |
|
I still think having a ton of boilerplate in the plugins' As I already mentioned, I'm ok with exclusions for things that should be in packages but not included in plugins. But most of this stuff shouldn't be in the packages in the first place, so rules excluding it (repeated in all the plugins) are just papering over a bug instead of fixing it. I'd also be ok with exclusions for stuff in third-party packages, particularly if we include a comment with each one pointing to the upstream issue requesting they fix their package (like we do for hacks in I can't stop you from going ahead with this as-is if you insist, and I won't try to revert it, but I think it's a bad approach that's creating fresh tech debt. |
|
@anomiex No, that makes sense. I'm going to mark this as blocked and revise to look at it from the package level. I was thinking it wouldn't hurt to have it at the plugin level, but reading your last comment landed. |
Fixes MONOREP-371
Proposed changes:
Plugin production mirrors (e.g. jetpack-production) are shipping development-only files from vendor packages that serve no purpose at runtime.
An audit of the production build (70M total) found ~4.5M of files that can be excluded via
.gitattributesproduction-exclude rules with zero runtime risk.Source files (commits 1-3)
production-excluderule existed for these**/src/css/*.scss) only matched a specific pathChangelogs, licenses, dev configs, docs (commit 4, revised in commit 5)
Not included (deferred per review)
Applied across all plugins
All 19 plugins with vendor includes are updated, plus the plugin skeleton template for newly scaffolded plugins.
Other information:
.gitattributeschanges are not testable via unit testsDoes this pull request change what data or activity we track or use?
No.
Testing instructions:
After merging + next mirror push, verify production mirrors no longer contain the excluded files:
Changelog
Changelog entries already included for all affected plugins.