-
Notifications
You must be signed in to change notification settings - Fork 800
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
Use webpack config JS package in Jetpack #21581
Conversation
This is intended to (eventually) take care of several issues in the monorepo: * Calypso [doesn't use their own calyspo-build webpack config][1], which means it's not likely to be well-maintained. * It needs a hack to [work with monorepo packages][2]. * And another to [get correct image paths][3]. * And it [tries to redefine NODE_ENV, producing warnings][4]. * And we have to [override a weird default everywhere][5]. * We have to [name our JS files with ".min.js"][6] to avoid their being broken by a wpcom minifier, but WordPress.org's translation infrastructure [ignores such files][7]. * The plugin used to fix the above [had to be forked][8], adds 772K to the plugin, and results in spurious changes in TC builds. * The way translations are [being loaded for lazy-loaded bundles][9] is pretty hacky and doesn't lazy-load them. * We can't use any cache busting for the lazy-loaded bundles, because embedding hashes in the filename breaks the link to the translation file and putting it in a query parameter [breaks building the RTL css][10]. * Webpack's minification is [losing translator comments][11]. * Calypso-build has a lot of peer dependencies we don't actually need. Not everything we have uses sass or postcss, and we have our own infrastructure for jest, react, and so on. Currently we just ignore the 76 warnings from that. This is the first step towards fixing that: creating a private package that can hold the webpack and babel config fragments that we can share throughout the monorepo. Then we'll have a place to put the fixes for some of the other issues too. [1]: #21004 (comment) [2]: Automattic/wp-calypso#53353 [3]: Automattic/wp-calypso#56111 [4]: Automattic/wp-calypso#56291 [5]: #21004 [6]: #20484 [7]: #21343 [8]: https://github.com/Automattic/jetpack/blob/7a5edd83/projects/plugins/jetpack/tools/webpack.helpers.js#L35 [9]: #20926 [10]: #21349 [11]: #16549
Mostly as a proof of concept. But I also took the opportunity to clean a few things up: * Name the built JS as ".min.js" like it should be. * Use copy-webpack-plugin to copy the src version of intersection-observer. * Use @wordpress/dependency-extraction-webpack-plugin to handle the cache-buster version in `wp_enqueue_script()`.
I tried not to change too much in this iteration, but I do note that the new package uses a newer version of @wordpress/browserslist-config than calyspo-build does so it now transpiles without IE11 support.
I tried not to change too much in this iteration, but I do note that the new package uses a newer version of @wordpress/browserslist-config than calyspo-build does so it now transpiles without IE11 support. Also I dropped babel-minify-webpack-plugin, as terser that's included with webpack seems to work just as well (and has been updated more recently than 4 years ago).
This results in no change to the production build. The development build is no longer actually minified.
This also reverts the "bring back the "Cloud" icon, the path changed after the Webpack update" bit from #20900. The problem was Automattic/wp-calypso#56111, which is not present in the new package.
This shouldn't change anything in this iteration, but double-checking might be a good idea. This does take the opportunity to fix the extension build to keep plugins and blocks in the order defined in extensions/index.json, where #20994 had put all the blocks before all the plugins.
Apparently it was somehow still finding it so the tests didn't fail.
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 🤖 The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available. Once your PR is ready for review, check one last time that all required checks (other than "Required review") appearing at the bottom of this PR are passing or skipped. Jetpack plugin:
Backup plugin:
|
…fig-js-package-in-jetpack
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Things seem to be fine here. Can't speak to the webpack code itself, but functionally all seems okay.
…fig-js-package-in-jetpack
Caution: This PR has changes that must be merged to WordPress.com |
Needs a fresh approval thanks to a merge conflict. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look reasonable and the builds work without issue. All Search products appear to be unaffected by the change.
👍
Great news! One last step: head over to your WordPress.com diff, D69704-code, and commit it. Thank you! |
r234651-wpcom |
# By renovate[bot] (3) and others # Via GitHub * master: Update dependency preact to v10.5.15 (#21635) Search: Migrate helper classes to standalone package (#21552) Release script: fix small typo (#21675) Update babel monorepo (#21668) Lock file maintenance (#21664) E2E tests: clean unused dependencies (#21639) Create JS Config package (#21592) Use webpack config JS package in Jetpack (#21581) add test runner to dev dependencies (#21591) Pexels Integration: Make the initial image search for example query run only once (#21641) Boost: make progress bar corners round on small screens (#21626) Full Sync :: limit to contributors and above (#21648) Sync Checksums : limit users based on user_level (#21645) Storybook: add Jetpack Spinner (#21511) Contact Info and Map widget: widget deprecation (#21554) Use webpack config js package in everything except Jetpack (#21580) # Conflicts: # pnpm-lock.yaml # projects/plugins/boost/package.json
* master: (24 commits) Update dependency preact to v10.5.15 (#21635) Search: Migrate helper classes to standalone package (#21552) Release script: fix small typo (#21675) Update babel monorepo (#21668) Lock file maintenance (#21664) E2E tests: clean unused dependencies (#21639) Create JS Config package (#21592) Use webpack config JS package in Jetpack (#21581) add test runner to dev dependencies (#21591) Pexels Integration: Make the initial image search for example query run only once (#21641) Boost: make progress bar corners round on small screens (#21626) Full Sync :: limit to contributors and above (#21648) Sync Checksums : limit users based on user_level (#21645) Storybook: add Jetpack Spinner (#21511) Contact Info and Map widget: widget deprecation (#21554) Use webpack config js package in everything except Jetpack (#21580) Boost: Fix the official name to the JavaScript word reference (#21638) tools: Allow extra spaces in next-version tags (#21647) Publicize: always add an alt text to Open Graph Images (#21520) js-tools: Add missing eslint plugin dep (#21642) ...
Changes proposed in this Pull Request:
This shouldn't change anything visible in this iteration, but double-checking
might be a good idea.
This does take the opportunity to fix the extension build to keep
plugins and blocks in the order defined in extensions/index.json,
where #20994 had put all the blocks before all the plugins.
This also replaces the uses of
@automattic/calypso-build
's jest configuration with local config.Jetpack product discussion
PT: p9dueE-3MG-p2
Does this pull request change what data or activity we track or use?
No
Testing instructions: