Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Node.js requirement in create-block docs. #60962

Merged
merged 3 commits into from
May 5, 2024

Conversation

kovshenin
Copy link
Contributor

What?

Updates minimum required Node.js version from 14.0.0 to 16.9.0:

Why?

The build currently fails with:

[webpack-cli] TypeError: Object.hasOwn is not a function
    at getBlockJsonScriptFields (.../node_modules/@wordpress/scripts/utils/block-json.js:28:15)
    at .../node_modules/@wordpress/scripts/utils/config.js:253:9

Object.hasOwn was introduced in Node.js 16.9.0.

Build fails with Node 14 because Object.hasOwn was introduced in Node 16.9.0:

```
[webpack-cli] TypeError: Object.hasOwn is not a function
    at getBlockJsonScriptFields (.../node_modules/@wordpress/scripts/utils/block-json.js:28:15)
    at .../node_modules/@wordpress/scripts/utils/config.js:253:9
```
Copy link

github-actions bot commented Apr 22, 2024

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: kovshenin <[email protected]>
Co-authored-by: gziolo <[email protected]>
Co-authored-by: carolinan <[email protected]>
Co-authored-by: Mamaduka <[email protected]>

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

@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Apr 22, 2024
Copy link

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @kovshenin! In case you missed it, we'd love to have you join us in our Slack community.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

@carolinan carolinan added the [Type] Developer Documentation Documentation for developers label Apr 23, 2024
@carolinan
Copy link
Contributor

Hi

I believe the npm version also needs to be increased, according to this table?
https://nodejs.org/en/about/previous-releases

The create-block/package.json file needs updating as well, it still says node version 14 or above:

	"engines": {
		"node": ">=14",
		"npm": ">=6.14.4"
	},

@carolinan carolinan added the [Tool] Create Block /packages/create-block label Apr 23, 2024
@gziolo
Copy link
Member

gziolo commented Apr 23, 2024

Good point about engines, @carolinan. This is what Gutenberg uses:

gutenberg/package.json

Lines 17 to 20 in 3d9bdee

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

It probably reflects actively supported Node.js versions: https://nodejs.org/en/about/previous-releases.

Maybe we should also support Node 18 which is in maintenance mode until April 2025.

@kovshenin
Copy link
Contributor Author

Set to 18/10.5 in 415a6ed given that 16 is no longer supported, though I should note that create-block worked fine with 16.9/8.19.

Copy link
Member

@gziolo gziolo left a comment

Choose a reason for hiding this comment

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

Nice, thank you so much for this patch.

I think we should add a changelog entry with the breaking changes section just for the sake of documentation purposes like in:
https://github.com/WordPress/gutenberg/blob/trunk/packages/create-block/CHANGELOG.md#breaking-change

I don't think @wordpress/create-block is used as a regular dependency in projects, but technically speaking it is a breaking change.

@gziolo
Copy link
Member

gziolo commented Apr 24, 2024

I think you still need to run npm i so the lock file updates with the engine changes.

@Mamaduka
Copy link
Member

Mamaduka commented May 5, 2024

I'm going to merge this. The Windows job failure is a known issue (a Slack link requires login).

@Mamaduka Mamaduka merged commit ea2e969 into WordPress:trunk May 5, 2024
58 of 59 checks passed
@github-actions github-actions bot added this to the Gutenberg 18.4 milestone May 5, 2024
@afercia
Copy link
Contributor

afercia commented May 6, 2024

Couple questions: really not my area of expertise but:

  • Why the npm version has been increased to >=10.5.0 only in the create-block package.json and not in the main package.json?
  • Shouldn't node/npm version changes be coordinated with Core?

For me, I was already on node 20.10.0 and npm 10.2.3. I guess that is what people who are contributing since a while have. I had to update only to get the new npm version. Core still requires npm greater or equal to 10.2.3.
Cc @desrosj

@gziolo
Copy link
Member

gziolo commented May 6, 2024

I missed the npm version being higher than 10.2.3. It definitely should align with what Gutenberg and WP core use.

In fact, for npm packages we should define 20.9.0 as the minimum required Node.js version based on the fact that it was the first LTS version: https://nodejs.org/en/blog/release/v20.9.0.

Node v20.9.0 comes with npm v10.1.0 so that should also be a minimum version used.

@afercia
Copy link
Contributor

afercia commented May 6, 2024

Thx for double checking @gziolo.
Are you on a follow-up for GB and Core?

@Mamaduka
Copy link
Member

Mamaduka commented May 7, 2024

I created a follow-up PR - #60962. Let's keep Gutneberg and Core versions in sync.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Tool] Create Block /packages/create-block [Type] Developer Documentation Documentation for developers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants