Skip to content

Jest: load components and block-editor as ESM, drop the pnpm patches - #54534

Merged
retrofox merged 11 commits into
trunkfrom
update/jest-esm-drop-wp-patches
Nov 11, 2026
Merged

retrofox merged 11 commits into
trunkfrom
update/jest-esm-drop-wp-patches

Conversation

@retrofox

@retrofox retrofox commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Proposed changes

Drop the two pnpm patches

#54512 added patches for @wordpress/components 44.0.0 and @wordpress/block-editor 20.0.0.

Their rolldown CommonJS builds evaluate a circular import before the exporting module has set its exports, so BaseControl reaches useBaseControlProps as undefined ("Invalid value used as weak map key") and InnerBlocks memoizes an undefined block list ("Element type is invalid").

Only Jest consumed those CommonJS builds. Webpack and wp-build take the ESM builds, so nothing that ships was ever patched.

This removes both patches from pnpm-workspace.yaml, .pnpm-patches/, and the lockfile.

Load them as ESM in Jest

jest-resolver.js swaps require for import on these two packages. The transform allowlist moves to transform-ignore.js so they get transpiled, and charts extends it instead of keeping its own.

Boost and Premium Analytics map @wordpress/components to an absolute path, which skips the resolver, so their mappers take the import entry through resolveMapperTarget().

It can all go once WordPress/gutenberg#86322 and WordPress/gutenberg#86323 ship.

Does this pull request change what data or activity we track or use?

No.

Testing instructions

Jest

Without the resolver entry this fails with 24 "Invalid value used as weak map key" errors.

cd projects/plugins/jetpack
pnpm run test-extensions extensions/blocks/subscriptions

Drops the pnpm patches for @wordpress/components 44 and @wordpress/block-editor 20: their rolldown CommonJS builds snapshot circular imports before the exports exist, which only jest consumed. A resolver takes the import entry for those two packages instead, and babel-jest's interop reads the bindings at use time. The transform allowlist moves to one helper so project configs extend it rather than replace it.
@retrofox
retrofox requested review from a team as code owners November 4, 2026 17:19
@retrofox retrofox added [Status] Needs Review This PR is ready for review. [Type] Janitorial labels Nov 4, 2026
@retrofox retrofox self-assigned this Nov 4, 2026
@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack or WordPress.com Site Helper), and enable the update/jest-esm-drop-wp-patches branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack update/jest-esm-drop-wp-patches
bin/jetpack-downloader test jetpack-mu-wpcom-plugin update/jest-esm-drop-wp-patches

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions github-actions Bot added [JS Package] Charts [Package] Premium Analytics [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Tests] Includes Tests RNA labels Nov 4, 2026
@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

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:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!


Jetpack plugin:

The Jetpack plugin has different release cadences depending on the platform:

  • WordPress.com Simple releases happen as soon as you deploy your changes after merging this PR (PCYsg-Jjm-p2).
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly:
    • Scheduled release: December 8, 2026
    • Code freeze: December 7, 2026

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.

@retrofox
retrofox marked this pull request as draft November 4, 2026 17:26
@github-actions github-actions Bot added [Status] In Progress and removed [Status] Needs Review This PR is ready for review. labels Nov 4, 2026
@jp-launch-control

Copy link
Copy Markdown

Code Coverage Summary

This 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. 🤷

Full summary · PHP report · JS report

Comment thread tools/js-tools/jest/resolver.js Resolved
config.base.js was shadowing jest-resolver.js, which swaps the browser condition for node on parsel-js; that is why parsel-js needed transforming. One resolver now does both, and the allowlist drops parsel-js.
@retrofox
retrofox marked this pull request as ready for review November 4, 2026 18:08
@retrofox retrofox added [Status] Needs Review This PR is ready for review. and removed [Status] In Progress labels Nov 4, 2026
@github-actions github-actions Bot added [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. and removed [Status] Needs Review This PR is ready for review. labels Nov 4, 2026
Comment thread tools/js-tools/jest/jest-resolver.js Resolved
Comment thread tools/js-tools/jest/jest-resolver.js Resolved
Comment thread tools/js-tools/jest/jest-resolver.js Resolved
@adamwoodnz adamwoodnz added [Status] Needs Review This PR is ready for review. and removed [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels Nov 4, 2026
@github-actions github-actions Bot added [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. and removed [Status] Needs Review This PR is ready for review. labels Nov 4, 2026
Nikschavan
Nikschavan previously approved these changes Nov 5, 2026

@Nikschavan Nikschavan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, the changes look good. I left one question inline about the Boost jest mapping, which still loads the CommonJS build of @wordpress/components.

Comment thread tools/js-tools/jest/jest-resolver.js Resolved
@retrofox retrofox added [Status] Needs Review This PR is ready for review. and removed [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels Nov 5, 2026
Co-authored-by: Brad Jorsch <anomiex@users.noreply.github.com>
@github-actions github-actions Bot added [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. and removed [Status] Needs Review This PR is ready for review. labels Nov 5, 2026

@louwie17 louwie17 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @retrofox, nice to get rid of the patches! The Jest runs I did went well: the Premium Analytics DataViews, backup, charts, forms and Jetpack GUI suites all pass, and InnerBlocks and ToggleGroupControl render fine in both the forms (ESM) and Jetpack extensions setups.

The main thing to fix is the Boost mapping @Nikschavan mentioned, I left a reply on that thread. The other one is a quick lint fix in jest.config.gui.js, which is currently failing the ESLint check.

Co-reviewed and tested with Claude and Codex.

@retrofox
retrofox requested a review from a team as a code owner November 10, 2026 12:42
@github-actions github-actions Bot added the [Plugin] Boost A feature to speed up the site and improve performance. label Nov 10, 2026
@retrofox retrofox added [Status] Needs Review This PR is ready for review. and removed [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels Nov 10, 2026

@anomiex anomiex left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable

@retrofox
retrofox merged commit 26ef4ab into trunk Nov 11, 2026
146 checks passed
@retrofox
retrofox deleted the update/jest-esm-drop-wp-patches branch November 11, 2026 08:34
@github-actions github-actions Bot removed the [Status] Needs Review This PR is ready for review. label Nov 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[JS Package] Charts [Package] Premium Analytics [Plugin] Boost A feature to speed up the site and improve performance. [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ RNA [Tests] Includes Tests [Type] Janitorial

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants