Skip to content

Fix IS_GUTENBERG_PLUGIN env var override in build config #76605

Merged
desrosj merged 5 commits intoWordPress:trunkfrom
mattgrshaw:fix/is-gutenberg-plugin-build-override
Mar 18, 2026
Merged

Fix IS_GUTENBERG_PLUGIN env var override in build config #76605
desrosj merged 5 commits intoWordPress:trunkfrom
mattgrshaw:fix/is-gutenberg-plugin-build-override

Conversation

@mattgrshaw
Copy link
Copy Markdown
Contributor

@mattgrshaw mattgrshaw commented Mar 17, 2026

What?

  • Changes || to ?? for IS_GUTENBERG_PLUGIN and IS_WORDPRESS_CORE config value resolution in packages/wp-build/lib/build.mjs.
  • Updates boolConfigVal to return undefined (instead of false) when the input value is not set, so that ?? correctly falls through to the npm_package_config_* fallback.
  • Applies the same ||?? fix to the isCoreBuild check for consistency.

Why?

When building for WordPress Core, it appears that the CI workflow sets IS_GUTENBERG_PLUGIN=false, but the || operator causes the fallback npm_package_config_IS_GUTENBERG_PLUGIN (always true from package.json) to take precedence:

// Current: boolConfigVal("false") || boolConfigVal("true") → false || true → true
boolConfigVal( process.env.IS_GUTENBERG_PLUGIN ) ||
    boolConfigVal( process.env.npm_package_config_IS_GUTENBERG_PLUGIN )

?? only falls through on null/undefined, so an explicit false from the env var is respected:

// Fixed: boolConfigVal("false") ?? boolConfigVal("true") → false ?? true → false
boolConfigVal( process.env.IS_GUTENBERG_PLUGIN ) ??
    boolConfigVal( process.env.npm_package_config_IS_GUTENBERG_PLUGIN )

For this fix to work, boolConfigVal must return undefined (not false) when the env var is unset — otherwise the fallback would not fall through to the package.json config default.

The same change is applied to IS_WORDPRESS_CORE for consistency. It does not appear to be affected currently since IS_WORDPRESS_CORE is not in the package.json config, but this prevents the same issue if it is added in the future.

Impact

globalThis.IS_GUTENBERG_PLUGIN is compiled to true in WordPress Core builds. This affects code paths guarded by this constant, including useShouldIframe() in edit-post, which forces the iframe editor on regardless of block API versions — preventing the block API version check introduced in #75187 from taking effect in the current WordPress 7.0 beta.

This was introduced in #75844 (commit 1bbed3c), where a coding standards cleanup changed ?? to ||.

Testing Instructions

Build Gutenberg with the IS_GUTENBERG_PLUGIN env var set to both true and false. Without this fix, the compiled JS will always evaluate to true. With the fix, the value of the env var is correctly used.

# Before fix (outputs true):
IS_GUTENBERG_PLUGIN=false npm run build
grep "isGutenbergPlugin" build/scripts/edit-post/index.js

# After fix (outputs false):
IS_GUTENBERG_PLUGIN=false npm run build
grep "isGutenbergPlugin" build/scripts/edit-post/index.js

# After fix without env var (outputs true)
npm run build
grep "isGutenbergPlugin" build/scripts/edit-post/index.js

Use of AI Tools

Cladue Code was used to troubleshoot and suggest code for this issue while looking into the related issue of the iframe being used in the post editor containing v2 blocks in WordPress 7.0-beta5.

Change `||` to `??` so that explicitly setting IS_GUTENBERG_PLUGIN=false in the environment correctly overrides the npm_package_config value from package.json. The `||` operator falls through on `false`, defeating the override when the package.json config is `true`.
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 17, 2026

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: mattgrshaw <mattshaw@git.wordpress.org>
Co-authored-by: desrosj <desrosj@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: aduth <aduth@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

boolConfigVal previously returned false for unset env vars, which prevented ?? from falling through to the npm_package_config_* fallback.

It now returns undefined when the value is not set, and a ?? false safety net ensures the defines still resolve to false when neither source provides a value.

Also applies the || → ?? fix to the isCoreBuild check for consistency.
@talldan talldan requested a review from desrosj March 18, 2026 07:58
@talldan talldan added the [Type] Build Tooling Issues or PRs related to build tooling label Mar 18, 2026
@desrosj desrosj requested a review from ockham March 18, 2026 10:26
Copy link
Copy Markdown
Member

@desrosj desrosj left a comment

Choose a reason for hiding this comment

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

Thanks @mattgrshaw!

I've pushed a few changes to two other IS_WORDPRESS_CORE checks for consistency. As far as I can tell, those were not technically problematic because the package.json file does not include the variable, but the same issue would present if it were.

I'd love you to confirm those changes look good to you before merging. Also going to see about getting a third person to have a look given that we're up against RC1 tomorrow. Would like to make sure we get this right.

@desrosj desrosj requested a review from aduth March 18, 2026 12:56
@aduth
Copy link
Copy Markdown
Member

aduth commented Mar 18, 2026

Cursory review: The problem and solution make sense to me 👍

Separately, I'd like to understand if we'll be moving away from / consolidating these variables. I thought r61873 removed the only place IS_WORDPRESS_CORE package config is actually being used (in build-gutenberg.js). Aren't we at the point where we could only consider the environment variable? At least for IS_WORDPRESS_CORE.

It'd also be nice to get IS_GUTENBERG_PLUGIN in this direction as well. Anecdotally I've heard reports of some versions of npm validating and warning about our misuse of package.json config:

npm warn Unknown cli config "IS_GUTENBERG_PLUGIN" (gutenberg:IS_GUTENBERG_PLUGIN). This will stop working in the next major version of npm.

Copy link
Copy Markdown
Member

@Mamaduka Mamaduka left a comment

Choose a reason for hiding this comment

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

The fix with the nullish coalescing operator makes sense.

+1 to @aduth suggestion. Having a single, not soon-deprecated source for these configs would be a good follow-up.

@desrosj
Copy link
Copy Markdown
Member

desrosj commented Mar 18, 2026

It'd also be nice to get IS_GUTENBERG_PLUGIN in this direction as well. Anecdotally I've heard reports of some versions of npm validating and warning about our misuse of package.json config:

I'm not 100% sure, but I believe that the intention is for this package to replace the build script from wp-scripts. So if other plugins are using this new script, there may be things that only should happen when building specifically for Gutenberg. Definitely worth getting clarification going forward.

If package.json config variables are not the preferred thing going forward, then maybe it shifts solely to environment variables instead after identifying what is still actually required and when.

@desrosj desrosj added the props-bot Manually triggers Props Bot to ensure the list of props is up to date. label Mar 18, 2026
@github-actions github-actions bot removed the props-bot Manually triggers Props Bot to ensure the list of props is up to date. label Mar 18, 2026
@desrosj desrosj merged commit 469e4c9 into WordPress:trunk Mar 18, 2026
48 of 50 checks passed
@desrosj desrosj added the Backport to WP 7.0 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Mar 18, 2026
@github-actions github-actions bot added this to the Gutenberg 22.8 milestone Mar 18, 2026
@github-actions github-actions bot removed the Backport to WP 7.0 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Mar 18, 2026
gutenbergplugin pushed a commit that referenced this pull request Mar 18, 2026
* Fix IS_GUTENBERG_PLUGIN env var override in build config

Change `||` to `??` so that explicitly setting IS_GUTENBERG_PLUGIN=false in the environment correctly overrides the npm_package_config value from package.json. The `||` operator falls through on `false`, defeating the override when the package.json config is `true`.

* Apply same fix to IS_WORDPRESS_CORE

* Fix boolConfigVal to return undefined for unset values

boolConfigVal previously returned false for unset env vars, which prevented ?? from falling through to the npm_package_config_* fallback.

It now returns undefined when the value is not set, and a ?? false safety net ensures the defines still resolve to false when neither source provides a value.

Also applies the || → ?? fix to the isCoreBuild check for consistency.

* Ensure proper fallback for `IS_WORDPRESS_CORE`

* Coding standards fixes.

---------

Co-authored-by: mattgrshaw <mattshaw@git.wordpress.org>
Co-authored-by: desrosj <desrosj@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: aduth <aduth@git.wordpress.org>
@github-actions github-actions bot added the Backported to WP Core Pull request that has been successfully merged into WP Core label Mar 18, 2026
@github-actions
Copy link
Copy Markdown

I just cherry-picked this PR to the wp/7.0 branch to get it included in the next release: 17df1f3

pento pushed a commit to WordPress/wordpress-develop that referenced this pull request Mar 19, 2026
This updates the pinned hash from the `gutenberg` from `8c78d87453509661a9f28f978ba2c242d515563b` to `487a096a9782ba6110a7686d7b4b2d0c55ed1b06`.

The following changes are included:

- Disables anchor support for the Page Break block. (WordPress/gutenberg#76434)
- WP Admin: Update Connectors screen footer text for consistency. (WordPress/gutenberg#76382)
- E2E Tests: Add coverage for AI plugin callout banner on Connectors page (WordPress/gutenberg#76432)
- Update sync docs (WordPress/gutenberg#75972)
- RTC: Add preference for collaborator notifications (WordPress/gutenberg#76460)
- Fix "should undo bold" flaky test (WordPress/gutenberg#76464)
- TimePicker: Clamp month day to valid day for month (WordPress/gutenberg#76400)
- RTC: Fix error when entity record doesn't have 'meta' property (WordPress/gutenberg#76311)
- Navigation: Update close button size. (WordPress/gutenberg#76482)
- TemplateContentPanel: fix useSelect warning (WordPress/gutenberg#76421)
- DataViews: Add spinner in `DataViewsLayout` in initial load of data (WordPress/gutenberg#76486) (WordPress/gutenberg#76490)
- RTC: Fix TypeError in areEditorStatesEqual when selection is undefined (WordPress/gutenberg#76163)
- Page/Post Content Focus Mode: Fix insertion into Post Content block (WordPress/gutenberg#76477)
- Revisions: use useSubRegistry={false} to fix global store selectors (WordPress/gutenberg#76152) (WordPress/gutenberg#76522)
- Fix RTL styling on Connectors, Font Library, and boot-based admin pages (WordPress/gutenberg#76496)
- RTC: Auto-register custom taxonomy rest_base values for CRDT sync (WordPress/gutenberg#75983)
- RTC: Add a limit for the default provider (WordPress/gutenberg#76437)
- Fix RTL styling on AI plugin callout banner (WordPress/gutenberg#76497)
- Add command palette trigger button to admin bar (WordPress/gutenberg#75757)
- Block Bindings: Remove source items constrained by enums (WordPress/gutenberg#76200)
- HTML Block: Remove "unsaved changes" check (WordPress/gutenberg#76086)
- CI: Don't build release notes during plugin build workflow for WP Core sync (WordPress/gutenberg#76398) (WordPress/gutenberg#76578)
- CI: Simplify strategy matrix in Build Gutenberg Plugin Zip workflow (WordPress/gutenberg#76435) (WordPress/gutenberg#76538)
- Media: Add hooks and extension points for client-side media processing (WordPress/gutenberg#74913)
- RTC: Fix list sidebar reset during real-time collaboration (WordPress/gutenberg#76025)
- RTC: Fix CRDT serialization of nested RichText attributes (WordPress/gutenberg#76597)
- RTC: Remove post list lock icon and replace user-specific lock text (WordPress/gutenberg#76322)
- Fix HEIC upload error handling and sub-size format (WordPress/gutenberg#76514)
- RTC: Fix cursor index sync with rich text formatting (WordPress/gutenberg#76418)
- RTC: Allow filtering of `SyncConnectionModal` (WordPress/gutenberg#76554)
- RTC: Implement front-end peer limits (WordPress/gutenberg#76565)
- Navigation overlay close button may be displayed twice (WordPress/gutenberg#76585)
- Site Editor > Templates: fix author filter (WordPress/gutenberg#76625)
- Revisions: Show changed block attributes in inspector sidebar (WordPress/gutenberg#76550)
- Fix IS_GUTENBERG_PLUGIN env var override in build config  (WordPress/gutenberg#76605)
- Real Time Collaboration: Introduce filters for the polling intervals. (WordPress/gutenberg#76518)
- RTC: Fix RichTextData deserialization (WordPress/gutenberg#76607)
- Cross Origin Isolation: Remove `img` from the list of elements that get mutated (WordPress/gutenberg#76618)
- RTC: Scroll to collaborator on click (WordPress/gutenberg#76561)
- Update changelog link for pull request 11276 (WordPress/gutenberg#76638)
- Fix backport changelog filename (WordPress/gutenberg#76651)
- Build: Skip non-minified build for WASM-inlined workers (WordPress/gutenberg#76615)
- RTC: Change RTC option name (WordPress/gutenberg#76643)
- BlockListBlock: fix crash when selectedProps are null (WordPress/gutenberg#75826)
- Build: Fix vips worker 404 when SCRIPT_DEBUG is true (WordPress/gutenberg#76657)
- useMediaQuery: support in-iframe queries via new `WindowContext` (WordPress/gutenberg#76446) (WordPress/gutenberg#76660)
- Refactor admin-ui Page component to use @wordpress/theme tokens and @wordpress/ui layout primitive (WordPress/gutenberg#75963)
- Connectors: Improve accessibility (WordPress/gutenberg#76456)
- Build: Remove unused JXL WASM module from vips worker (WordPress/gutenberg#76639)
- Connectors: fix button size (WordPress/gutenberg#76582)
- Compose: Implement useCopyToClipboard and useCopyOnClick with native clipboard API (WordPress/gutenberg#75723) (WordPress/gutenberg#76663)
- Connectors: Fetch specific plugin instead of all plugins (WordPress/gutenberg#76594)
- Revisions: Add Meta fields diff panel to document sidebar (WordPress/gutenberg#76341)
- Loosen client-side media processing requirements (WordPress/gutenberg#76616)
- Reduce the added halo for selected block. (WordPress/gutenberg#76619)
- Connectors: Add unregisterConnector and upsert support (WordPress/gutenberg#76541)

A full list of changes can be found on GitHub: https://github.com/WordPress/gutenberg/compare/8c78d87453509661a9f28f978ba2c242d515563b…487a096a9782ba6110a7686d7b4b2d0c55ed1b06.

Log created with:

git log --reverse --format="- %s" 8c78d87453509661a9f28f978ba2c242d515563b..487a096a9782ba6110a7686d7b4b2d0c55ed1b06 | sed 's|#\([0-9][0-9]*\)|https://github.com/WordPress/gutenberg/pull/\1|g; /github\.com\/WordPress\/gutenberg\/pull/!d' | pbcopy

See #64595.

git-svn-id: https://develop.svn.wordpress.org/trunk@62063 602fd350-edb4-49c9-b593-d223f7449a82
markjaquith pushed a commit to markjaquith/WordPress that referenced this pull request Mar 19, 2026
This updates the pinned hash from the `gutenberg` from `8c78d87453509661a9f28f978ba2c242d515563b` to `487a096a9782ba6110a7686d7b4b2d0c55ed1b06`.

The following changes are included:

- Disables anchor support for the Page Break block. (WordPress/gutenberg#76434)
- WP Admin: Update Connectors screen footer text for consistency. (WordPress/gutenberg#76382)
- E2E Tests: Add coverage for AI plugin callout banner on Connectors page (WordPress/gutenberg#76432)
- Update sync docs (WordPress/gutenberg#75972)
- RTC: Add preference for collaborator notifications (WordPress/gutenberg#76460)
- Fix "should undo bold" flaky test (WordPress/gutenberg#76464)
- TimePicker: Clamp month day to valid day for month (WordPress/gutenberg#76400)
- RTC: Fix error when entity record doesn't have 'meta' property (WordPress/gutenberg#76311)
- Navigation: Update close button size. (WordPress/gutenberg#76482)
- TemplateContentPanel: fix useSelect warning (WordPress/gutenberg#76421)
- DataViews: Add spinner in `DataViewsLayout` in initial load of data (WordPress/gutenberg#76486) (WordPress/gutenberg#76490)
- RTC: Fix TypeError in areEditorStatesEqual when selection is undefined (WordPress/gutenberg#76163)
- Page/Post Content Focus Mode: Fix insertion into Post Content block (WordPress/gutenberg#76477)
- Revisions: use useSubRegistry={false} to fix global store selectors (WordPress/gutenberg#76152) (WordPress/gutenberg#76522)
- Fix RTL styling on Connectors, Font Library, and boot-based admin pages (WordPress/gutenberg#76496)
- RTC: Auto-register custom taxonomy rest_base values for CRDT sync (WordPress/gutenberg#75983)
- RTC: Add a limit for the default provider (WordPress/gutenberg#76437)
- Fix RTL styling on AI plugin callout banner (WordPress/gutenberg#76497)
- Add command palette trigger button to admin bar (WordPress/gutenberg#75757)
- Block Bindings: Remove source items constrained by enums (WordPress/gutenberg#76200)
- HTML Block: Remove "unsaved changes" check (WordPress/gutenberg#76086)
- CI: Don't build release notes during plugin build workflow for WP Core sync (WordPress/gutenberg#76398) (WordPress/gutenberg#76578)
- CI: Simplify strategy matrix in Build Gutenberg Plugin Zip workflow (WordPress/gutenberg#76435) (WordPress/gutenberg#76538)
- Media: Add hooks and extension points for client-side media processing (WordPress/gutenberg#74913)
- RTC: Fix list sidebar reset during real-time collaboration (WordPress/gutenberg#76025)
- RTC: Fix CRDT serialization of nested RichText attributes (WordPress/gutenberg#76597)
- RTC: Remove post list lock icon and replace user-specific lock text (WordPress/gutenberg#76322)
- Fix HEIC upload error handling and sub-size format (WordPress/gutenberg#76514)
- RTC: Fix cursor index sync with rich text formatting (WordPress/gutenberg#76418)
- RTC: Allow filtering of `SyncConnectionModal` (WordPress/gutenberg#76554)
- RTC: Implement front-end peer limits (WordPress/gutenberg#76565)
- Navigation overlay close button may be displayed twice (WordPress/gutenberg#76585)
- Site Editor > Templates: fix author filter (WordPress/gutenberg#76625)
- Revisions: Show changed block attributes in inspector sidebar (WordPress/gutenberg#76550)
- Fix IS_GUTENBERG_PLUGIN env var override in build config  (WordPress/gutenberg#76605)
- Real Time Collaboration: Introduce filters for the polling intervals. (WordPress/gutenberg#76518)
- RTC: Fix RichTextData deserialization (WordPress/gutenberg#76607)
- Cross Origin Isolation: Remove `img` from the list of elements that get mutated (WordPress/gutenberg#76618)
- RTC: Scroll to collaborator on click (WordPress/gutenberg#76561)
- Update changelog link for pull request 11276 (WordPress/gutenberg#76638)
- Fix backport changelog filename (WordPress/gutenberg#76651)
- Build: Skip non-minified build for WASM-inlined workers (WordPress/gutenberg#76615)
- RTC: Change RTC option name (WordPress/gutenberg#76643)
- BlockListBlock: fix crash when selectedProps are null (WordPress/gutenberg#75826)
- Build: Fix vips worker 404 when SCRIPT_DEBUG is true (WordPress/gutenberg#76657)
- useMediaQuery: support in-iframe queries via new `WindowContext` (WordPress/gutenberg#76446) (WordPress/gutenberg#76660)
- Refactor admin-ui Page component to use @wordpress/theme tokens and @wordpress/ui layout primitive (WordPress/gutenberg#75963)
- Connectors: Improve accessibility (WordPress/gutenberg#76456)
- Build: Remove unused JXL WASM module from vips worker (WordPress/gutenberg#76639)
- Connectors: fix button size (WordPress/gutenberg#76582)
- Compose: Implement useCopyToClipboard and useCopyOnClick with native clipboard API (WordPress/gutenberg#75723) (WordPress/gutenberg#76663)
- Connectors: Fetch specific plugin instead of all plugins (WordPress/gutenberg#76594)
- Revisions: Add Meta fields diff panel to document sidebar (WordPress/gutenberg#76341)
- Loosen client-side media processing requirements (WordPress/gutenberg#76616)
- Reduce the added halo for selected block. (WordPress/gutenberg#76619)
- Connectors: Add unregisterConnector and upsert support (WordPress/gutenberg#76541)

A full list of changes can be found on GitHub: https://github.com/WordPress/gutenberg/compare/8c78d87453509661a9f28f978ba2c242d515563b…487a096a9782ba6110a7686d7b4b2d0c55ed1b06.

Log created with:

git log --reverse --format="- %s" 8c78d87453509661a9f28f978ba2c242d515563b..487a096a9782ba6110a7686d7b4b2d0c55ed1b06 | sed 's|#\([0-9][0-9]*\)|https://github.com/WordPress/gutenberg/pull/\1|g; /github\.com\/WordPress\/gutenberg\/pull/!d' | pbcopy

See #64595.
Built from https://develop.svn.wordpress.org/trunk@62063


git-svn-id: http://core.svn.wordpress.org/trunk@61345 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Backported to WP Core Pull request that has been successfully merged into WP Core [Type] Build Tooling Issues or PRs related to build tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants