Exclude dev files from production builds at the package level#47365
Exclude dev files from production builds at the package level#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. |
| /tests/** production-exclude | ||
| /build-compat-rulesets.sh production-exclude | ||
| /check-docs.sh production-exclude | ||
| docs/** production-exclude |
There was a problem hiding this comment.
This will break the doc link to https://github.com/Automattic/jetpack-codesniffer/tree/trunk/docs/Jetpack.Functions.JsonEncodeFlags.Recommendations.md from JsonEncodeFlagsSniff.
If we want to exclude the docs from vendor/ dirs, using export-ignore would be better here.
| /src/js/** production-exclude | ||
| babel.config.js production-exclude | ||
| webpack.config.js production-exclude | ||
| tsconfig.json production-exclude |
There was a problem hiding this comment.
Is the tsconfig.json listing in the monorepo root .gitattributes not taking effect?
Also, we've already got eslint and phpunit configs in there. I wonder whether we should go ahead and add some of these there too. babel.config.js, webpack.config.js, .phpcs.dir.xml, and maybe even /projects/*/*/changelog/** and /projects/*/*/tests/** seem like decent candidates.
Fixes #MONOREP-371
Proposed changes
Per code review feedback, moves dev file exclusions from plugin-level
.gitattributes(where they targetedvendor/automattic/**) to the package level, where they belong architecturally. The build process builds packages first (applying their.gitattributes), then installs them into plugins via Composer path repos — so package-level exclusions propagate automatically.production-excluderules for source files (.ts,.tsx,.jsx,.scss) and build configs (webpack.config.js,babel.config.js,tsconfig.json,jest.config.js, etc.) to 18 package.gitattributesfiles.gitattributesvendor exclusion changes from previous commitsPackages updated
Group A — Source files + build configs: woocommerce-analytics, jetpack-mu-wpcom, external-media, newsletter, forms, search, backup, paypal-payments, external-connections, subscribers-dashboard, publicize
Group B — Build configs only: blaze, classic-theme-helper, connection, explat, my-jetpack, yoast-promo
Group C — Dev directories only: codesniffer
Not included (deferred)
*.map) — Tracked in MONOREP-394src/css/*.scssrules — Follow-up after this landsOther information
Related product discussion/links
Does this pull request change what data or activity we track or use?
No.
Testing instructions
jp build --for-mirrorsforjetpackand spot-check that excluded files (e.g.,.ts,webpack.config.js) don't appear in the build output undervendor/automattic/woocommerce-analyticsto confirm.tsfiles are gone from the build