Make WordPress Core

Opened 20 months ago

Closed 10 months ago

Last modified 7 months ago

#56658 closed task (blessed) (fixed)

Make build process compatible with newer versions of NodeJS/npm

Reported by: desrosj's profile desrosj Owned by: desrosj's profile desrosj
Milestone: 6.4 Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords: has-patch
Focuses: Cc:

Description (last modified by desrosj)

The build scripts and processes currently require NodeJS 14.x and NPM < 7 (6.x).

Some notes:

  • NodeJS 14.x is currently in the maintenance phase, which ends April, 30, 2023.
  • NodeJS 16.x (the current LTS version) enters the maintenance phase on October 18, 2022.
  • NodeJS 18.x enters LTS on October 25, 2022.
  • NPM 7 introduces a new lock file format (see #52951).
  • NPM 8 had only one notable breaking change, dropping support for NodeJS 10.
  • Twenty Nineteen, Twenty Twenty, and Twenty Twenty-One all have their own package.json files and are set up to run on NodeJS 14.x. These should probably be updated as well so that the version required is consistent.

Change History (29)

#1 @desrosj
20 months ago

Since 18.x will enter LTS in late October, it may make sense to skip transitioning to 16.x all together. However, it's possible that some dependencies will need a bit more time to release a version that supports 18.x, so a two phase update may also be reasonable.

#2 @desrosj
20 months ago

  • Description modified (diff)

This ticket was mentioned in Slack in #core by desrosj. View the logs.


20 months ago

#4 @desrosj
20 months ago

#52951 was marked as a duplicate.

#5 @desrosj
16 months ago

  • Milestone changed from 6.2 to 6.3

Unfortunately, I haven't had the time to make any progress on this for 6.2.

Going to punt, but to 6.3 as this needs to be done before the maintenance window for 14.x ends in April.

@gziolo is back from his leave, so I'm going to make an effort to tackle this with him in Gutenberg and Core in the coming weeks.

#6 @ironprogrammer
12 months ago

Noting here that 16.x is scheduled for EOL on September 11, 2023, moved forward seven months sooner, as explained in this announcement (full schedule).

#7 @desrosj
10 months ago

  • Milestone changed from 6.3 to 6.4

This is not going to be done for 6.3.

In speaking with @youknowriad the last few weeks, the plan is to address this before the end of July accompanied by a post on Making WordPress Core.

#8 @desrosj
10 months ago

  • Owner set to desrosj
  • Status changed from new to assigned

This ticket was mentioned in PR #4028 on WordPress/wordpress-develop by @desrosj.


10 months ago
#9

  • Keywords has-patch added

This updates the version of NodeJS used for WordPress Core to 16.x.

18.x is not currently an option because of system level adjustments that need to be made in order for the build server and other .org infrastructure to properly support 18.x. See this post for more context.

Trac ticket: https://core.trac.wordpress.org/ticket/56658

@swissspidy commented on PR #4028:


10 months ago
#10

https://github.com/WordPress/gutenberg/pull/53426 was just merged in Gutenberg to bump to Node 16 🎉

So let's make it happen 🚀

@gziolo commented on PR #4028:


10 months ago
#11

It's very likely that we will have to use the following config line here as well:

https://github.com/WordPress/gutenberg/blob/4a24e8560cb5c277ea90631ad81e3453933bc27e/.npmrc#L3

legacy-peer-deps = true

@desrosj commented on PR #4028:


10 months ago
#12

Flagged for review from a few folks that showed interest in this.

I've gone and merged in the latest trunk, and also added legacy-peer-deps.

One thing I'd like to confirm before merging this is why there are changes in the src/wp-includes folder as a result. My hunch is that there is an update to uuid being applied that is the reason.

@swissspidy commented on PR #4028:


10 months ago
#13

One thing I'd like to confirm before merging this is why there are changes in the src/wp-includes folder as a result. My hunch is that there is an update to uuid being applied that is the reason.

Just picked wordcount.js to look at, because it has a changed hash as well. I ran npm run build:dev on trunk and then on this PR. All the diffs were just because functions were replaced with arrow functions:

https://i0.wp.com/github.com/WordPress/wordpress-develop/assets/841956/155caf26-2bed-4d7c-b6f7-36d995afa1cb

(left is trunk, right is this PR)

@youknowriad commented on PR #4028:


10 months ago
#14

I'm guessing that the update of the package-lock.json also updated some packages and among these packages is probably browser-list which includes the browser usage which probably changed slightly making arrow functions a syntax that is supported in all the supported browsers so it's not transpiled anymore.

I think that's fine.

@gziolo commented on PR #4028:


10 months ago
#15

@swissspidy, what if you run npx browserslist@latest --update-db in both places? Beside, it's very likely that we see a different set of dependencies in both branches, including webpack. I also think that Node 16 is using a different hashing algorithm by default so it would also impact the versions calculated for packages. I remember some fixes in Gutenberg for Node 17 and above like https://github.com/WordPress/gutenberg/issues/36471.

@gziolo commented on PR #4028:


10 months ago
#16

It would be great to fix the following:

https://i0.wp.com/github.com/WordPress/wordpress-develop/assets/699132/e0963e3f-e75c-4ca9-818b-8125b09b4390

@desrosj commented on PR #4028:


10 months ago
#17

Resolving some of the vulnerabilities reported in this commit or with a follow-up would be great.

Agreed! I plan to do a follow-up commit that upgrades all other dependencies to their latest versions that were not specifically required to make this upgrade work.

Thanks everyone! I'll get this committed shortly.

#18 @desrosj
10 months ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 56378:

Build/Test Tools: Bump the required versions of Node.js and npm.

This changes the minimum required version of Node.js to 16.19.1, and npm to 8.19.3.

Node.js 14.x reached end of life on April 30, 2023. While 18.x is the currently active LTS version, it can’t yet be used due to a systems level constraint on the build server.

Updating further will be considered once this blocker is resolved.

Gutenberg has also been updated to follow the same version requirements for consistency.

Props youknowriad, gziolo, swissspidy, kevin940726, desrosj.
Fixes #56658.

#19 @desrosj
10 months ago

I've published a note about this on Making WordPress Core: https://make.wordpress.org/core/2023/08/09/updating-wordpress-to-use-more-modern-versions-of-node-js-npm/.

It's likely there will be some documentation and handbook updates required. I called that out in the post and asked folks to call them out in appropriate locations.

@desrosj commented on PR #4028:


10 months ago
#20

Merged in Core-56378. Post also published. Thanks all!

This ticket was mentioned in Slack in #core by lkraav. View the logs.


10 months ago

#22 @desrosj
9 months ago

In 56387:

Build/Test Tools: Update the README file to reflect new Node.js/npm versions.

Follow up to [56378].

Props dantovbein, hbhalodia.
Fixes #59071. See #56658.

#23 @oglekler
9 months ago

@desrosj I assume that in README should be written:

Note: WordPress currently only officially supports Node.js 16.x (16.19.1 and higher) and npm 8.x.

I tried to use 16.13.1 and only from the error message got the correct number.

#24 @desrosj
9 months ago

In 56442:

Build/Test Tools: Change the version of Node.js in the Codespaces container.

Follow up to [56378] and [56387].

Props jeffpaul.
See #56658.

#25 @desrosj
9 months ago

In 56531:

Bundled Themes: Use Node.js 16.x in themes with a build process.

This results in a new package-lock.json file being generated that uses lockfileVersion 2.x.

There are no changes to built files as a result of this update.

Follow up to [56378], [56387], [56442].

Props mikestraw, whyisjake, jivygraphics.
Fixes #59187. See #56658.

#26 @desrosj
9 months ago

In 56532:

Bundled Themes: Set legacy-peer-deps to true.

While npm install was working without issue after [56531], npm ci was not. The latter expects dependencies in the package-lock.json to match those in package.json exactly.

Follow up to [56378], [56387], [56442], [56531[.

Fixes #59187. See #56658.

#27 @benharri
7 months ago

This is latest trunk as of r56831 and node 18 lts. Seems that npm v9 is the blocker.

$ npm ci
npm ERR! code EBADENGINE
npm ERR! engine Unsupported engine
npm ERR! engine Not compatible with your version of node/npm: WordPress@6.4.0
npm ERR! notsup Not compatible with your version of node/npm: WordPress@6.4.0
npm ERR! notsup Required: {"node":">=16.19.1","npm":">=8.19.3 <9"}
npm ERR! notsup Actual:   {"npm":"9.6.4","node":"v18.12.1"}

$ node -v
v18.12.1

$ npm -v
9.6.4

#28 @desrosj
7 months ago

@benharri updating to 18.x is currently unsupported (as of WordPress 6.4).

Please follow #59663 for progress towards allowing 18.x.

#29 @benharri
7 months ago

ah I must've read the wrong page! I was following this local setup guide https://learn.wordpress.org/tutorial/installing-node-js-and-npm-for-local-wordpress-development/

Note: See TracTickets for help on using tickets.