gutenberg icon indicating copy to clipboard operation
gutenberg copied to clipboard

Preserve `engines` field in published `@wordpress/create-block` package

Open zzap opened this issue 1 year ago • 3 comments

What problem does this address?

Currently, the package.json for @wordpress/create-block in the Gutenberg repo includes an engines field:

"engines": {
  "node": ">=20.10.0",
  "npm": ">=10.2.3"
}

However, in the published package on npm, this field appears to be removed during the publishing process. As a result, commands like:

npm view @wordpress/create-block engines

return nothing, which makes it impossible to check the required Node/npm versions programmatically without visiting the documentation.

I managed to get this info by running:

curl -L -o create-block.tgz "$(npm view @wordpress/create-block dist.tarball)"

and

tar -xOf create-block.tgz package/package.json | node -e "console.log(JSON.stringify(JSON.parse(require('fs').readFileSync(0,'utf8')).engines,null,2))"

which is not ideal for regular use. Especially when there is a command to get this info easily.

Expected behavior

The engines field should be preserved in the published npm package so that developers can easily verify the requirements before running installation process.

Why this matters?

  • Improves developer experience by allowing quick CLI checks for compatibility.
  • Prevents unnecessary install failures or confusion.
  • Keeps the published manifest consistent with the repository manifest.

Steps to reproduce

  • Run npm view @wordpress/create-block engines → returns nothing.
  • Check repo’s package.json → engines field present.

What is your proposed solution?

Adjust the publishing process (possibly in the monorepo’s build script) so that the engines field from the source package.json is retained in the published package.

zzap avatar Aug 13 '25 09:08 zzap

Run npm view @wordpress/create-block engines → returns nothing.

In my environment, I can get the information correctly 🤔

  • What are your node and Npm versions?
  • Which registry are you referencing? You can check with the npm config get registry command. I think https://registry.npmjs.org/ is the default.

Windows 11

Image

WSL2 (Ubuntu 22.04.4)

Image

t-hamano avatar Aug 13 '25 11:08 t-hamano

I'm also getting the information correctly on my environment

macOS 15.6

Image

BugReportOnWeb avatar Aug 13 '25 13:08 BugReportOnWeb

Yeah, I installed node 20 (my newest on system was 18, Kubuntu 24.04) and now I get the output. Kind of irony. Thank you both for testing out and quick responses.

zzap avatar Aug 13 '25 16:08 zzap