Skip to content

Framework: Update Node.js to v24 (wp/5.1) - #86869

Draft
sirreal wants to merge 11 commits into
wp/5.1from
build/node-24-wp-5.1
Draft

sirreal wants to merge 11 commits into
wp/5.1from
build/node-24-wp-5.1

Conversation

@sirreal

@sirreal sirreal commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

What?

Sets .nvmrc to Node.js 24.20 on wp/5.1, as on trunk, and makes the branch install, build and run its unit tests with Node.js 24 and npm 11.

Why?

The wordpress-develop 5.1 branch moves to Node.js 24 in WordPress/wordpress-develop#15699. This branch's CI takes Node.js from .nvmrc, and with only that change npm ci fails on Node.js 24 and npm 11.

How?

  • .nvmrc is 24.20.
  • Package styles build with Dart Sass: the node-sass devDependency (LibSass 4.14.1, which has no Node.js 24 binary and does not compile against it) becomes npm:sass@1.32.8, the sass version WordPress 5.1 uses. bin/packages/build.js passes Sass an importer that returns node_modules/react-dates/lib/css/_datepicker.css as SCSS: Dart Sass reads an imported .css file as plain CSS and rejects its darken() call, which LibSass compiled.
  • A root overrides entry sets node-gyp to 12.4.0, the version npm 11 bundles. deasync, which bin/packages/build.js uses, has no Node.js 24 prebuild and compiles with the node-gyp in node_modules/.bin; the locked 3.8.0 needs Python 2. 12.4.0 is outside the ^3.8.0 range that lerna's npm-lifecycle declares.
  • Backports Build Tooling: Remove WebpackRTLPlugin #15711, which removes webpack-rtl-plugin from package.json and webpack.config.js. npm 11 cannot install the plugin from its git source: it runs the package's prepublish build, and its babel 6 devDependency is a placeholder package with no compiler. bin/packages/build.js already writes each -rtl.css file, which webpack copies, so the build writes the same files as before.
  • build and dev run webpack as node --openssl-legacy-provider ./node_modules/webpack/bin/webpack.js, because webpack 4 hashes with md4, which OpenSSL 3 disables.
  • test-unit runs @wordpress/scripts' test-unit-js.js with node --openssl-legacy-provider --unhandled-rejections=warn, which is what wp-scripts test-unit-js ran. Two test suites run webpack inside Jest, and the gallery block test leaves an api-fetch promise rejected, which ends the Jest process on Node.js 15 and later. Node.js 14 only warned.
  • test-e2e and the E2E workflow run @wordpress/scripts' test-e2e.js with node --unhandled-rejections=warn, which is what wp-scripts test-e2e ran. A Puppeteer wait still pending when a spec closes its page rejects ("Protocol error (Runtime.callFunctionOn): Target closed."), which ends the in-band Jest run on Node.js 24 before the remaining specs report.
  • .npmrc sets legacy-peer-deps = true, npm 6's peer dependency handling. Without it npm 11 rejects the lockfile: ajv-keywords asks for peer ajv ^6.0.0, and the hoisted ajv is 5.5.2.
  • Converts package-lock.json from lockfile version 1 to 3 with npm 11. Installed versions change only through the changes above: node-sass 4.14.1 is replaced by sass 1.32.8 and node-sass's dependencies are removed; node-gyp moves from 3.8.0 to 12.4.0, which moves graceful-fs from 4.1.11 to 4.2.11, nopt from 3.0.6 to 9.0.0, abbrev from 1.1.1 to 4.0.0, tar from 2.2.1 to 7.5.23 and node-gyp's semver from 5.3.0 to 7.8.6, removes block-stream and fstream, and adds 15 entries that node-gyp 12 and tar 7 need; webpack-rtl-plugin and the packages only it used are removed. Three nested entries under listr that no package requires are dropped.

Testing Instructions

With Node.js 24 and npm 11: npm ci && npm run build && npm run test-unit.

The built JavaScript and every other non-CSS file is byte-identical to a Node.js 14 build of wp/5.1, and the unit test results are the same. The built CSS has the same rules; Dart Sass writes them in a different notation: 10 decimals instead of 5, @charset "UTF-8" with literal characters instead of escapes in content, unquoted attribute selector values, hex instead of rgb(), and one @media block per rule instead of merged blocks.

Use of AI Tools

AI assistance: Yes
Tools: Claude Code
Model: Claude Opus 5.5
Used for: Applying the changes, backporting the PR, regenerating the lockfile, building and testing on Node.js 14 and 24 and comparing the output, and drafting this description.

sirreal and others added 10 commits November 12, 2026 10:21
Matches trunk's .nvmrc. Node.js 24.20 bundles npm 11.19.
LibSass (node-sass 4.14.1) has no Node.js 24 binary and does not compile against Node.js 24. node-sass becomes an alias of sass 1.32.8, the version WordPress 5.1 builds its own styles with. bin/packages/build.js keeps calling renderSync().

Dart Sass reads an imported .css file as plain CSS, so the react-dates stylesheet, which calls darken(), fails to compile. An importer passes that file to Sass as SCSS, as LibSass read it.
deasync builds its binding with the node-gyp in node_modules/.bin. Lerna's npm-lifecycle installs node-gyp 3.8.0 there, which needs Python 2. node-gyp 12.4.0 is the version npm 11.19 bundles, and builds deasync on Node.js 24 with Python 3.
npm 11 prepares git dependencies that have a build script by installing their devDependencies and running the build. webpack-rtl-plugin's build fails there, because its `babel` devDependency is the Babel 6 no-op package. The tarball of the same commit, fc5a2f2, installs the committed lib/ without preparing it, as npm 6 did.
webpack 4 hashes with md4, which OpenSSL 3 disables, so webpack and the Jest tests that run webpack get --openssl-legacy-provider. Jest also gets --unhandled-rejections=warn, Node.js 14's behavior: a test that leaves an api-fetch request rejected (window.fetch is not defined in the test environment) otherwise ends the run on Node.js 15 and later.
npm 11 converts the npm 6 lockfile to lockfileVersion 3, which the Static Analysis job's `npm install` would otherwise do on every run. `legacy-peer-deps = true` makes npm 11 resolve peer dependencies as npm 6 did; without it, `npm ci` rejects the lockfile because ajv-keywords asks for a peer ajv 6 while the hoisted ajv is 5.5.2.

Versions change only where the previous commits require it: sass 1.32.8 replaces node-sass 4.14.1 and its dependencies, and node-gyp 12.4.0 replaces 3.8.0, which moves the hoisted graceful-fs from 4.1.11 to 4.2.11 and nopt, abbrev and tar to node-gyp 12's versions. No runtime dependency changes.
…k-rtl-plugin (wp/5.1)

Removes webpack-rtl-plugin and the 114 dependency paths only it used. No other path, version, resolved URL or integrity changes.
@sirreal sirreal added the [Type] Build Tooling Issues or PRs related to build tooling label Nov 16, 2026
@coderabbitai

coderabbitai Bot commented Nov 16, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

On Node.js 24 a promise rejected after a spec closes its page ("Protocol error (Runtime.callFunctionOn): Target closed." from a pending Puppeteer wait) ends the in-band Jest run, so the remaining specs never report. Node.js 14 only warned. The E2E workflow and the test-e2e script run wp-scripts' test-e2e.js with the flag, since wp-scripts would start it in a new process that does not receive it.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Type] Build Tooling Issues or PRs related to build tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants