Skip to content

fix: Upgrade @wordpress/format-library and fix PlainText CJS interop#323

Open
dcalhoun wants to merge 4 commits intotrunkfrom
fix/format-library-upgrade
Open

fix: Upgrade @wordpress/format-library and fix PlainText CJS interop#323
dcalhoun wants to merge 4 commits intotrunkfrom
fix/format-library-upgrade

Conversation

@dcalhoun
Copy link
Member

@dcalhoun dcalhoun commented Feb 16, 2026

What?

Upgrade @wordpress/format-library from 5.36.0 to 5.38.0 and fix a PlainText component crash caused by Vite's CJS interop with .mjs packages.

Supersedes #285.

Why?

Dependabot bumped @wordpress/format-library to 5.38.0, which also pulled in @wordpress/block-editor@15.11.0. The new .mjs build output triggers esbuild's Node-style CJS interop during Vite dependency pre-bundling, causing react-autosize-textarea's default export (a ForwardRef component) to be wrapped as a module object. This crashes the Shortcode block with:

type is invalid -- expected a string or class/function but got: object

How?

  1. Cherry-picked the dependabot version bump for @wordpress/format-library (5.36.0 → 5.38.0)
  2. Regenerated patch files for the upgraded packages (@wordpress/format-library 5.36.0 → 5.38.0, @wordpress/block-editor 15.10.0 → 15.11.0)
  3. Added a react-autosize-textarea patch that fixes the CJS interop issue at the source by removing the __esModule flag and switching from exports["default"] to module.exports. This is the same patch used by the upstream Gutenberg project.

Testing Instructions

  • Run npm ci — patches should apply cleanly
  • Verify CI tasks pass (including the Shortcode block test)

Accessibility Testing Instructions

No UI changes — this is a dependency upgrade and build fix.

@dcalhoun dcalhoun added [Type] Bug An existing feature does not function as intended dependencies Pull requests that update a dependency file labels Feb 16, 2026
@dcalhoun dcalhoun force-pushed the fix/format-library-upgrade branch from f85d276 to 80ba09d Compare February 17, 2026 14:47
- Allow setting popover props for the `Inserter` component, so we can improve the mobile screen reader experience by marking it as a modal dialog.
- Prevent the insertion point popover from appearing on touch devices in `InserterListItem`. The popover (triggered by `onMouseEnter`) disrupts tap/click events, requiring users to tap inserter items twice before they are inserted.
- Fix `PlainText` component crash caused by esbuild's `.mjs` CJS interop wrapping `react-autosize-textarea`'s default export as a module object instead of the actual React component. WordPress packages switched their build output from `.js` to `.mjs` starting in v15.11, which triggers Node-style interop in Vite's dependency pre-bundling.
- Add `./build-module/components/inserter/media-tab/*` and `./build-module/components/inserter/hooks/*` to the package's `exports` field to allow importing internal inserter modules used by the native inserter component. Note: Creating this patch required using `--exclude='^$'` due to a [patch-package limitation](https://github.com/ds300/patch-package/issues/250).
Copy link
Member Author

Choose a reason for hiding this comment

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

The "Add" line documents a preexisting patch.

Base automatically changed from test/e2e to trunk February 18, 2026 01:26
dependabot bot and others added 3 commits February 17, 2026 21:58
Bumps [@wordpress/format-library](https://github.com/WordPress/gutenberg/tree/HEAD/packages/format-library) from 5.36.0 to 5.38.0.
- [Release notes](https://github.com/WordPress/gutenberg/releases)
- [Changelog](https://github.com/WordPress/gutenberg/blob/trunk/packages/format-library/CHANGELOG.md)
- [Commits](https://github.com/WordPress/gutenberg/commits/@wordpress/format-library@5.38.0/packages/format-library)

---
updated-dependencies:
- dependency-name: "@wordpress/format-library"
  dependency-version: 5.38.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Regenerate patches for @wordpress/format-library (5.36.0 -> 5.38.0)
and @wordpress/block-editor (15.10.0 -> 15.11.0). The underlying
fixes are unchanged; only the target versions were updated. The
block-editor patch also adds deep module exports for the inserter
media-tab and hooks paths.
WordPress packages v15.11+ switched build output from .js to .mjs,
which triggers esbuild's Node-style CJS interop during Vite dependency
pre-bundling. This caused react-autosize-textarea's default export (a
ForwardRef component) to be wrapped as a module object instead of the
component itself, crashing the Shortcode block with "type is invalid --
expected a string or class/function but got: object".

The patch unwraps the default import when it resolves to a module object.
Also adds deep module exports for the inserter media-tab and hooks paths.
@dcalhoun dcalhoun force-pushed the fix/format-library-upgrade branch from 80ba09d to f1f6a07 Compare February 18, 2026 02:58
…-textarea patch

Replace our consumer-side workaround in `@wordpress/block-editor`'s
`plain-text/index.mjs` with Gutenberg's upstream patch that fixes the
root cause in `react-autosize-textarea` directly. The new patch removes
the `__esModule` flag and switches from `exports["default"]` to
`module.exports`, preventing Vite's esbuild pre-bundling from wrapping
the default export as a module object.
Copy link
Member Author

Choose a reason for hiding this comment

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

Regenerate this existing patch to capture Gutenberg's move to ECMAScript modules (ESM) in WordPress/gutenberg#74348.

Copy link
Member Author

Choose a reason for hiding this comment

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

Regenerate this existing patch to capture Gutenberg's move to ECMAScript modules (ESM) in WordPress/gutenberg#74348.

Copy link
Member Author

Choose a reason for hiding this comment

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

This applies the same patch used by the Gutenberg project to address the following issue.

This is an unfortunate necessity. Without this, inserting blocks that rely upon Gutenberg's PlainText component (e.g., Shortcode, Jetpack AI Assistant) result in a "This block has encountered an error and cannot be previewed" message and an error:

Warning: React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: object.

Gutenberg's PlainText component relies upon an unmaintained react-autosize-textarea library. Gutenberg has long attempted to drop this dependency. It relies upon CommonJS modules (CJS).

The patch is now required as Gutenberg's recently embraced ECMAScript modules (ESM) in WordPress/gutenberg#74348. Gutenberg's patch was added in WordPress/gutenberg#73822.

With #313, the Shortcode block is now covered by automated E2E tests to ensure this regression is not present.

@dcalhoun dcalhoun marked this pull request as ready for review February 18, 2026 17:23
@dcalhoun dcalhoun requested a review from kean February 18, 2026 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments