Skip to content

build: compile theme assets on Node 24 - #445

Merged
mmcky merged 2 commits into
mainfrom
maint/node24-stb
Sep 18, 2026
Merged

mmcky merged 2 commits into
mainfrom
maint/node24-stb

Conversation

@mmcky

@mmcky mmcky commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

This moves the Node that compiles the theme's CSS and JS from 20.18.0 to 24.21.0. It is part of the Node 24 upgrade across the QuantEcon lecture and theme fleets (see QuantEcon/workspace-themes#31): an audit after #441 merged found this pin still on Node 20, even though every setup-node step and .nvmrc already say 24.

Why the workflows' Node 24 was not enough

pyproject.toml pins node-version under [tool.sphinx-theme-builder]. sphinx-theme-builder (0.3.2, which the >= 0.2.0a7 build requirement resolves to) runs python -m nodeenv --node=<pin> --prebuilt to install exactly that Node into .nodeenv/, and that Node runs npm install --include=dev and npm run-script build (webpack) for every wheel it builds, editable or not. So every path that builds the theme compiled its assets on Node 20.18.0, whatever setup-node said:

Where Step Built on, before this PR
tests.yml publish (v* tags) python -m build, the wheel published to PyPI 20.18.0
tests.yml tests pip install -e .[test] 20.18.0
ci.yml build pip install ., the theme the fixtures site and Playwright tests use 20.18.0
docs.yml build pip install -e .[doc], which rebuilds the assets over the npm run build before it 20.18.0
update-snapshots.yml, both jobs pip install . of the PR branch, before regenerating baselines 20.18.0
local pip install -e ., tox, stb compile 20.18.0

#401 moved the setup-node steps and .nvmrc to 24 but not this line, and #441 did not touch it.

What changes

File From To
pyproject.toml [tool.sphinx-theme-builder] node-version 20.18.0 24.21.0
.nvmrc 24 24.21.0
docs/developer/setup.md, troubleshooting example mismatch v18.18.0 against v20.18.0 v20.18.0 against v24.21.0, plus a note that .nvmrc moves with the pin
CHANGELOG.md an Unreleased "Changed" entry, including the two costs below (90b899f)

24.21.0 is the current Node 24 LTS (Krypton, released 2026-09-07, bundling npm 11.19.0), and it is the pin QuantEcon/quantecon-sphinx-theme#9 set today. The pin has to be a full version: sphinx-theme-builder compares node --version from .nodeenv/ with it and stops with nodeenv-version-mismatch on any difference, so a bare 24 cannot work here.

.nvmrc follows the pin exactly. quantecon-sphinx-theme set its .nvmrc to the same 24.21.0 as its pyproject.toml, and this does the same. No workflow here reads .nvmrc; it is what nvm use reads for local development. With 24, nvm takes the newest 24.x installed, so running npm run build or the Playwright suite directly could run on a different Node from the one sphinx-theme-builder builds with. With the full version the two pins agree. The costs are that the next Node bump has to change both lines, which the setup guide now says, and that a developer with only another 24.x installed has to run nvm install once per bump, since nvm use only switches to a version already installed. quantecon-sphinx-theme#9 accepted the same trade-off.

The setup-node steps stay at '24'. In ci.yml (visual) and update-snapshots.yml they run only npm ci and Playwright. In docs.yml the editable install that follows npm run build recompiles the assets on the nodeenv's Node. So none of them builds an asset that ships. On this PR's visual job, '24' resolved to 24.20.0 from the runner's tool cache ("Found in cache @ /opt/hostedtoolcache/node/24.20.0/x64"), so Playwright runs on a different 24.x from the build. quantecon-sphinx-theme moved its docs.yml to node-version-file: .nvmrc after review. That would also work here, but docs.yml runs only on main and update-snapshots.yml only from the default branch, so this PR's CI could not test it. I have left it for a separate decision.

Compatibility:

  • sphinx-theme-builder 0.3.2: create_nodeenv passes the pin straight to nodeenv, and nothing in it depends on the Node major.
  • nodeenv 1.10.0, the version installed alongside it, builds the download URL from the version string. node-v24.21.0-linux-x64.tar.gz and node-v24.21.0-darwin-arm64.tar.gz both return HTTP 200 from nodejs.org.
  • Source builds need a Node 24 platform. nodejs.org ships no Node 24 binary for 32-bit ARM Linux or 32-bit Windows: node-v24.21.0-linux-armv7l.tar.gz and node-v24.21.0-win-x86.zip return 404, and the release index lists neither platform for v24.21.0, while v20.18.0 had both. So building from source there (an sdist, pip install --no-binary, or a git install) now fails when nodeenv downloads Node. The py3-none-any wheel on PyPI is unaffected, and its contents are byte-identical (below). 90b899f adds this and the nvm install note to the CHANGELOG entry.
  • package.json has no engines field. Seven dev dependencies need a newer Node than 20.18.0, and the 20.18.0 build printed an EBADENGINE warning for each: [email protected] (>= 22.11.0), [email protected] (>= 22.15.0), [email protected] (^22.15.0 or ^24), [email protected] (>= 22), [email protected], [email protected] and [email protected] (>= 20.19.0). On 24.21.0 there are none.

Local build comparison

On macOS arm64 with Python 3.13, I built main (e45f676) and this branch side by side in two ways. python -m build builds the sdist and then the wheel from it, as the publish job does, and pip wheel . builds in the tree, as ci.yml and tests.yml install. Both builds used sphinx-theme-builder 0.3.2.

main this branch
nodeenv --node=20.18.0, node --version v20.18.0, npm 10.8.2 --node=24.21.0, node --version v24.21.0, npm 11.19.0
npm install --include=dev 438 packages, 7 EBADENGINE warnings 438 packages, no engine warnings
webpack 5.108.3 CSS 83.1 KiB, JS 13.5 KiB the same
wheel contents 54 files the same 54 files, all byte-identical (diff -r on the unpacked wheels, both build routes)

The compiled quantecon-book-theme.css (sha256 6ceb0664…), quantecon-book-theme.js (bd38cf87…) and their source maps are identical. This PR changes the Node that builds the assets, not the assets. package-lock.json is unchanged after npm 11's npm install, and the two sdists differ only in pyproject.toml. On macOS, npm 11.19.0 also prints an install-scripts notice for [email protected], a macOS-only optional dependency. It does not fail the build.

After merging, locally

A checkout that already has a .nodeenv/ stops at nodeenv-version-mismatch on the next tox or pip install -e .: "There is a mismatch between what is present in the environment (v20.18.0) and the expected version of NodeJS (v24.21.0)". I reproduced this. Running rm -rf .nodeenv clears it. The setup guide's troubleshooting section already covers this case and now shows that exact message.

What this PR's CI proves

On the final head, 7974131, every check passed in runs 35344279350 (continuous-integration) and 35344279392 (Build Fixtures Site for Visual Regression Tests):

Check Result
pre-commit passed
tests, Python 3.12 and 3.13 with Sphinx 7 and 8 (4 jobs) passed
build (fixtures site, jb build . --warningiserror) passed
visual (Playwright) passed: 103 passed, 3 skipped, the same counts as on #441
preview, Netlify, codecov/patch, codecov/project passed
Publish to PyPi skipped, as it runs only on v* tags

Which Node built the assets. pip hides a build backend's output when the build succeeds, so the normal CI log shows no Node version, on main or here. To get it into a log, I pushed a temporary commit, 99ee5ce, which added -v to the pip install in ci.yml build and in tests.yml tests. Once its runs finished, I force-pushed the branch back to 7974131. Those runs, 35343662470 and 35343662475, passed, and each of the five theme builds (the fixtures build and the four tests jobs) logged:

  • [stb] # Generating new nodeenv with NodeJS 24.21.0!
  • [stb] $ python -m nodeenv --node=24.21.0 --prebuilt --clean-src, then * Install prebuilt node (24.21.0)
  • v24.21.0, from sphinx-theme-builder's node --version check
  • added 438 packages, and audited 439 packages, with no npm warn or EBADENGINE line, then webpack 5.108.3 compiled successfully and [stb] Done!

A green build implies the pin even without those lines. sphinx-theme-builder stops with nodeenv-version-mismatch unless node --version equals the pin exactly, and no workflow sets STB_RELAX_NODE_VERSION_CHECK or STB_USE_SYSTEM_NODE.

Compiled output. The fixtures-build artifact from 35344279392 (91 files) is byte-identical to the one from the main push run 35339629263 on e45f676, which was built on Node 20.18.0. That includes _static/styles/quantecon-book-theme.css, _static/scripts/quantecon-book-theme.js and their source maps, whose sha256 hashes also match the local macOS builds above. The repository does not commit compiled assets, so the Playwright snapshots are its only snapshot comparison, and they pass without regeneration.

Not exercised here:

  • tests.yml publish runs only on v* tags. The local python -m build comparison above follows the same route and gave identical wheels, but the first PyPI build on 24.21.0 will be the next release.
  • docs.yml runs only on push to main and on workflow_dispatch, so its first run on the new pin will be the merge.
  • update-snapshots.yml runs only on an /update-snapshots comment, and nobody ran it on this PR. It builds with pip install . from the PR branch, so it takes whichever pin that branch carries.

🤖 Generated with Claude Code

sphinx-theme-builder installs the Node pinned in pyproject.toml
([tool.sphinx-theme-builder] node-version) into .nodeenv/ and uses it
for npm install and webpack in every wheel build: the PyPI release in
tests.yml, the CI and docs installs, and local installs. That pin was
still 20.18.0 after #401 moved setup-node and .nvmrc to Node 24, so
the shipped assets were still compiled on Node 20.

Move the pin to 24.21.0, the current Node 24 LTS (Krypton), the same
pin QuantEcon/quantecon-sphinx-theme#9 set. .nvmrc moves from "24" to
the same exact version, as that repository did, so nvm gives local
development the Node the build uses. sphinx-theme-builder refuses a
nodeenv whose node --version differs from the pin, so the two pins
cannot drift silently in the build, only in .nvmrc.

Built locally with python -m build and pip wheel . on both pins, the
wheels' contents are identical, compiled CSS, JS and source maps
included. The seven npm EBADENGINE warnings the Node 20.18.0 install
printed (sass-loader 17 wants >= 22.11.0, among others) are gone.

The troubleshooting example in docs/developer/setup.md now shows the
mismatch error an existing .nodeenv/ will raise after this change.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Copilot AI lite review requested due to automatic review settings September 18, 2026 12:08
@github-actions

github-actions Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

@github-actions
github-actions Bot temporarily deployed to pull request September 18, 2026 12:09 Inactive

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The changes are a straightforward version-pin alignment across config/docs/changelog with no functional code changes and consistent updates to all referenced locations.

Pull request overview

This PR aligns the Node.js version used for theme asset compilation (via sphinx-theme-builder/nodeenv) with the repo’s Node 24 upgrade by pinning Node 24.21.0 in the build configuration and syncing local developer tooling/docs accordingly.

Changes:

  • Update pyproject.toml’s [tool.sphinx-theme-builder].node-version from 20.18.0 to 24.21.0 so wheels/editable installs build assets on Node 24.
  • Pin .nvmrc to 24.21.0 so nvm use matches the build pin exactly.
  • Update developer troubleshooting docs and add an Unreleased changelog entry documenting the change and the .nodeenv cleanup step.
File summaries
File Description
pyproject.toml Bumps the sphinx-theme-builder Node pin to 24.21.0 (affects asset compilation during builds/installs).
.nvmrc Pins local nvm usage to the same exact Node version as the build pin.
docs/developer/setup.md Updates troubleshooting example text and notes that .nvmrc moves with the pinned build Node version.
CHANGELOG.md Records the Node 24.21.0 asset-compilation pin change under Unreleased.
Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@codecov

codecov Bot commented Sep 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@e45f676). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #445   +/-   ##
=======================================
  Coverage        ?   56.30%           
=======================================
  Files           ?        2           
  Lines           ?      547           
  Branches        ?        0           
=======================================
  Hits            ?      308           
  Misses          ?      239           
  Partials        ?        0           
Flag Coverage Δ
pytests 56.30% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

🎭 Visual Regression Test Results

passed  103 passed
skipped  3 skipped

Details

stats  106 tests across 1 suite
duration  3 minutes, 45 seconds
commit  90b899f

Skipped tests

desktop-chrome › theme.spec.ts › Visual Regression Tests › prob-matrix - full page screenshot
mobile-chrome › theme.spec.ts › Visual Regression Tests › prob-matrix - full page screenshot
mobile-chrome › theme.spec.ts › Theme Features › f-string interpolation styling

@github-actions
github-actions Bot temporarily deployed to pull request September 18, 2026 12:15 Inactive
@github-actions
github-actions Bot temporarily deployed to pull request September 18, 2026 12:22 Inactive
A source build now needs a platform nodejs.org ships a Node 24 binary
for, which excludes linux-armv7l and 32-bit Windows (both have Node
20.18.0 builds, neither has 24.21.0); the py3-none-any wheel is
unaffected. And with .nvmrc pinned exactly, nvm use needs one nvm
install per bump.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@github-actions
github-actions Bot temporarily deployed to pull request September 18, 2026 12:39 Inactive
@mmcky
mmcky merged commit 4176e26 into main Sep 18, 2026
12 checks passed
@mmcky
mmcky deleted the maint/node24-stb branch September 18, 2026 23:15
@mmcky mmcky mentioned this pull request Oct 9, 2026

This branch was previously deployed

1 inactive deployment
pull request — 90b899ff Deployed Sep 18, 2026 by github-actions[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants