Skip to content

Conversation

@dcalhoun
Copy link
Member

@dcalhoun dcalhoun commented Dec 3, 2025

What?

Upgrade dependencies to the latest versions.

Why?

Integrate the latest bug fixes and features.

How?

  • Upgrade all @wordpress packages.
  • Remove now unnecessary @wordpress/components patch.
  • Recreate existing @wordpress packages for new dependency versions.
  • Expand patches to export overlooked @wordpress/editor and @wordpress/format-library stylesheets.
  • Expand patches to export private modules utilized by GutenbergKit.
  • Replace usage of private getLayoutStyles API with new public export from the @wordpress/global-styles-engine package.
  • Defer upgrading the following packages due to incompatibility with the Gutenberg core project:
  • Add legacy-peer-deps=true to address optional @typescript-eslint/utils dependency version conflict. See e9f99f4.
  • Add tsconfig.json to address new (mistaken?) tsconfig.json requirement by @wordpress/eslint-plugin. See e9f99f4.

Testing Instructions

Broadly test various aspects of the editor to avoid regressions.

Accessibility Testing Instructions

No specific user-facing changes to test.

Screenshots or screencast

No user-facing changes.

@dcalhoun dcalhoun added the [Type] Build Tooling Issues or PRs related to build tooling label Dec 3, 2025
Enable importing the package's CSS files, which is promoted as an option
in the Gutenberg Framework documentation: https://wordpress.org/gutenberg-framework/docs/intro#bootstrap-your-block-editor

The package `exports` field was added in: WordPress/gutenberg@f13dcfa

Without these exports, Vite's build fails with the following error:

```
(!) Failed to run dependency scan. Skipping dependency pre-bundling. Error:   Failed to scan for dependencies from entries:
  ./GutenbergKit/src/index.html

  ✘ [ERROR] Missing "./build-style/style.css" specifier in "@wordpress/format-library" package [plugin vite:dep-scan]

    src/utils/editor-styles.js:11:7:
      11 │ import '@wordpress/format-library/build-style/style.css';
         ╵        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  This error came from the "onResolve" callback registered here:

    node_modules/esbuild/lib/main.js:1151:20:
      1151 │       let promise = setup({
           ╵                     ^

    at setup (file://./GutenbergKit/node_modules/vite/dist/node/chunks/config.js:31620:12)
    at handlePlugins (./GutenbergKit/node_modules/esbuild/lib/main.js:1151:21)

```
This existing import resulted in the following Vite build error. This
began occurring after upgrading the package. Presumably, this began
occurring due to the addition of the `exports` field to the package in:
WordPress/gutenberg@f13dcfa

```
(!) Failed to run dependency scan. Skipping dependency pre-bundling. Error: The following dependencies are imported but could not be resolved:

  @wordpress/core-commands (imported by ./GutenbergKit/src/utils/wordpress-globals.js)

Are they installed?
    at file://./GutenbergKit/node_modules/vite/dist/node/chunks/config.js:31896:33
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async file://./GutenbergKit/node_modules/vite/dist/node/chunks/config.js:34104:15

```
Disable externalization of `raw` imports as the global does not provide
the required ability to inline the raw imported value.
Load these styles in the editor block canvas `iframe` to minimize
potential style collisions in the top-level editor. These styles are
only intended for content within the editor, not the editor UI itself.
Rely upon the "toolbar" `variant` configuration to ensure each toolbar
group renders a separating right border.
@dcalhoun dcalhoun force-pushed the build/upgrade-dependencies branch from c8da5eb to f0f168c Compare December 4, 2025 15:50
This
`@wordpress/eslint-plugin@22.21.0` changed the import resolution
behavior. This is incompatible with the GutenbergKit project for an
unknown reason, possibly the lack of TypeScript setup.

```
Unable to resolve path to module '[module_name]'  import/no-unresolved
```

See: https://github.com/WordPress/gutenberg/blob/2d2571507d8ea76f263089c98c46110403e3eba3/packages/eslint-plugin/CHANGELOG.md#22210-2025-11-12
With the previous mock, the entire `@wordpress/data` module was
replaced. This led to emptying utilities like `createReduxStore`. This
resulted in other `@wordpress` modules throwing errors when attempting
to act upon stores.

```
 FAIL  src/utils/editor.test.jsx [ src/utils/editor.test.jsx ]
Error: Cannot unlock an undefined object.
 ❯ unlock node_modules/@wordpress/private-apis/src/implementation.ts:186:9
 ❯ node_modules/@wordpress/blocks/src/store/index.js:31:1
 ❯ node_modules/@wordpress/blocks/src/index.js:11:1
```
@dcalhoun dcalhoun force-pushed the build/upgrade-dependencies branch from 9d7c3e2 to 6dced9e Compare December 4, 2025 17:34
The latest version of `@vitejs/plugin-react` is ESM-only. This is
incompatible with `@wordpress/eslint-plugin`'s usage of
`eslint-import-resolver-node`. Once `eslint-import-resolver-node` is
upgraded or replaced with a more capable alternative, we can remove
the `eslint-disable-line` comments.

Resulting error:

```
Unable to resolve path to module '@vitejs/plugin-react'  import/no-unresolved
```

See: vitejs/vite-plugin-react#691 (comment)
`tsconfig.json` introduced as `@wordpress/eslint-plugin`'s replaced its
usage of `eslint-import-resolver-node` with
`eslint-import-resolver-typescript`. Those changes now require a
`tsconfig.json` file to ensure the resolver works properly. The
`tsconfig.json` does not add TypeScript support.

See: WordPress/gutenberg@a4ba451#diff-691525462f8b4cac47c3c2e0e2668606f539ed0b3f62f8f6b79dffe7ef38bd9d

`legacy-peer-deps=true` introduced to address a dependency version
conflict. See Claude's explanation:

> 1. eslint-import-resolver-typescript@4.4.4 has an optional peer dependency on eslint-plugin-import-x
> 2. eslint-plugin-import-x requires @typescript-eslint/utils@^8.0.0
> 3. @wordpress/eslint-plugin@22.22.0 depends on @typescript-eslint/eslint-plugin@^6.4.1, which uses @typescript-eslint/utils@6.21.0
>
> So we have:
> - @typescript-eslint/utils@6.21.0 (from @wordpress/eslint-plugin chain)
> - @typescript-eslint/utils@8.48.1 (wanted by eslint-plugin-import-x, optional peer of the resolver)
>
> Since eslint-plugin-import-x is marked as optional in the resolver, using --legacy-peer-deps should be safe. The resolver will work without it - it's
> an alternative to eslint-plugin-import for those who want to use it.

Once `@wordpress/eslint-plugin` updates its `@typescript-eslint`
dependencies to v8.x, we can remove the `legacy-peer-deps` usage.
These styles overrode foundational styles causing unexpected layout
bugs. E.g., the theme styles removed the top margin from image blocks.
This is no strictly necessary currently as we disable `shouldIframe`,
but it further aligns GutenbergKit with Gutenberg.
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 replaces patches/@wordpress+block-editor+14.17.0.patch one-for-one, aside from the inline comment below.

Comment on lines +63 to +64
+ "./build-module/components/inserter/media-tab/*": "./build-module/components/inserter/media-tab/*",
+ "./build-module/components/inserter/hooks/*": "./build-module/components/inserter/hooks/*"
Copy link
Member Author

Choose a reason for hiding this comment

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

Given GutenbergKit accesses private modules paths, we must explicitly export these modules now that @wordpress/block-editor defines exports of its own.

Copy link
Member Author

Choose a reason for hiding this comment

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

No changes. This existing patch was recreated for the new @wordpress/block-library version.

},
- "./package.json": "./package.json"
+ "./package.json": "./package.json",
+ "./build-style/*": "./build-style/*"
Copy link
Member Author

Choose a reason for hiding this comment

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

@wordpress/editor seemingly mistakenly overlooks exporting its styles. This needs to be contributed to the upstream WordPress/gutenberg repository.

},
- "./package.json": "./package.json"
+ "./package.json": "./package.json",
+ "./build-style/*": "./build-style/*"
Copy link
Member Author

Choose a reason for hiding this comment

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

@wordpress/format-library seemingly mistakenly overlooks exporting its styles. This needs to be contributed to the upstream WordPress/gutenberg repository.

store: { name: 'core/editor' },
} ) );
vi.mock( '@wordpress/data' );
vi.mock( import( '@wordpress/data' ), { spy: true } );
Copy link
Member Author

Choose a reason for hiding this comment

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

Fix test failures by using the original module rather than a partial mock that caused errors within other @wordpress modules.

@@ -0,0 +1 @@
legacy-peer-deps=true
Copy link
Member Author

Choose a reason for hiding this comment

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

Used to fix a @typescript-eslint/utils dependency conflict. See e9f99f4.

Copy link
Member Author

Choose a reason for hiding this comment

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

Does not add TypeScript support. Added to address a new (mistaken?) TypeScript configuration requirement by @wordpress/eslint-plugin. See e9f99f4.

const imports = defaultImport || namedImports;

if ( module.match( /\.css\?inline$/ ) ) {
if ( module.match( /\.css\?(inline|raw)$/ ) ) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Added for robustness and avoid cryptic. There is no active use of Vite's raw query parameter at the present.

window.wp.commands = commands;
window.wp.components = components;
window.wp.compose = compose;
window.wp.coreCommands = coreCommands;
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 module began throwing errors related to unresolved modules, likely due to the new exports usage in Gutenberg packages.

I opted to remove the module entirely, as the WP Admin commands library feels unrelated to (and presumably unused in) the mobile editor.

Comment on lines +95 to +98
componentStyles,
blockEditorContentStyles,
blocksStyles,
blocksEditorStyles
Copy link
Member Author

Choose a reason for hiding this comment

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

Relocated from utils/editor-styles to scope their loading to the block canvas iframe, per the Gutenberg Framework guides.

@dcalhoun dcalhoun marked this pull request as ready for review December 5, 2025 00:45
@dcalhoun dcalhoun requested a review from kean December 5, 2025 00:45
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 patch was removed as it is no longer necessary after WordPress/gutenberg@01d3959.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Type] Build Tooling Issues or PRs related to build tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants