Skip to content

Conversation

@t-hamano
Copy link
Contributor

@t-hamano t-hamano commented Dec 11, 2025

What?

This PR fixes an issue where some files in the theme package fail to build on Windows OS.

npm run --workspace @wordpress/theme build                     

> @wordpress/[email protected] build
> npm run build:tokens && npm run build:default-ramps


> @wordpress/[email protected] build:tokens
> node --import=esbuild-esm-loader/register bin/generate-primitive-tokens/index.ts && cross-env NODE_OPTIONS=--import=esbuild-esm-loader/register tz build --config terrazzo.config.ts

🎨 Starting primitive color tokens generation...
✅ Successfully updated color.json (31.74ms)
✗  Invalid URL
npm error Lifecycle script `build:tokens` failed with error:
npm error code 1
npm error path D:\Desktop\wp_dev\gutenberg\packages\theme
npm error workspace @wordpress/[email protected]
npm error location D:\Desktop\wp_dev\gutenberg\packages\theme
npm error command failed
npm error command C:\WINDOWS\system32\cmd.exe /d /s /c node --import=esbuild-esm-loader/register bin/generate-primitive-tokens/index.ts && cross-env NODE_OPTIONS=--import=esbuild-esm-loader/register tz build --config terrazzo.config.ts
npm error Lifecycle script `build` failed with error:
npm error code 1
npm error path D:\Desktop\wp_dev\gutenberg\packages\theme
npm error workspace @wordpress/[email protected]
npm error location D:\Desktop\wp_dev\gutenberg\packages\theme
npm error command failed
npm error command C:\WINDOWS\system32\cmd.exe /d /s /c npm run build:tokens && npm run build:default-ramps

Why?

This is where the error is occurring.

On Mac, outFile looks like this.

/home/path/to/gutenberg/packages/theme/tokens/modes/border.high-dpi.json
/home/path/to/_core-dev/gutenberg/packages/theme/tokens/modes/dimension.compact.json
/home/path/to/_core-dev/gutenberg/packages/theme/tokens/modes/dimension.comfortable.json

On Windows, it looks like this.

D:\Desktop\path\to\gutenberg\packages\theme\tokens\modes\border.high-dpi.json
D:\Desktop\path\to\gutenberg\packages\theme\tokens\modes\dimension.compact.json
D:\Desktop\path\to\gutenberg\packages\theme\tokens\modes\dimension.comfortable.json

I'm not sure the exact reason, but passing an absolute path as the outputFile argument may not work on certain OS. Indeed, it seems that a relative path is recommended.

https://github.com/terrazzoapp/terrazzo/blob/d4b958faa59c8dd9279402521d818f62121fbf28/packages/parser/src/types.ts#L38

https://github.com/terrazzoapp/terrazzo/blob/d4b958faa59c8dd9279402521d818f62121fbf28/www/src/pages/docs/reference/plugin-api.md?plain=1#L399

How?

I converted the absolute path to a relative path and it seems to work.

Testing Instructions

  • Manually delete packages\theme\tokens\modes
  • Run npm run --workspace @wordpress/theme build
  • The file should be generated correctly and there should be no diff.

@t-hamano t-hamano added [Type] Bug An existing feature does not function as intended OS Issues Issues or PRs that are related to OS specific problems [Package] Theme /packages/theme labels Dec 11, 2025
@t-hamano t-hamano changed the title Theme Fix build failure of mode overrides plugin on Windows OS Theme: Fix build failure of mode overrides plugin on Windows OS Dec 11, 2025
@t-hamano t-hamano force-pushed the fix/theme-windows-build branch from eec682c to 0adfa14 Compare December 11, 2025 04:38
@t-hamano t-hamano self-assigned this Dec 11, 2025
@t-hamano t-hamano requested a review from a team December 11, 2025 04:39
@github-actions
Copy link

Flaky tests detected in 0adfa14.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/20122155127
📝 Reported issues:

@t-hamano t-hamano marked this pull request as ready for review December 11, 2025 05:39
@github-actions
Copy link

github-actions bot commented Dec 11, 2025

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: t-hamano <[email protected]>
Co-authored-by: aduth <[email protected]>

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

Copy link
Member

@aduth aduth left a comment

Choose a reason for hiding this comment

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

Thanks for the fix, and sorry for another breakage. I'll take some solace in that this doesn't feel like a particularly obvious bug 😅

To be clear, none of the comments are blocking. Would rather get the fix out and deal with those considerations later.

} ),
pluginModeOverrides(),
pluginModeOverrides( {
filePath: '../../tokens/modes',
Copy link
Member

Choose a reason for hiding this comment

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

In this context I might suggest some sort of "dir" (similar to outDir above) or "base" naming, since "path" could be ambiguous to a file rather than a directory.

) }.${ mode }.json`;

const outputFilePath = join(
filePath,
Copy link
Member

Choose a reason for hiding this comment

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

We could probably avoid the extra option by using path.resolve if Terrazzo exposes the current working directory somehow (i.e. resolve the relative path from where Terrazzo will output by default vs. where the file we're looking at is).

@aduth
Copy link
Member

aduth commented Dec 11, 2025

This was fixed separately in #73911.

@aduth aduth closed this Dec 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

OS Issues Issues or PRs that are related to OS specific problems [Package] Theme /packages/theme [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants