Repository navigation
build: compile theme assets on Node 24 - #445
Conversation
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]>
There was a problem hiding this comment.
🟢 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-versionfrom 20.18.0 to 24.21.0 so wheels/editable installs build assets on Node 24. - Pin
.nvmrcto 24.21.0 sonvm usematches the build pin exactly. - Update developer troubleshooting docs and add an Unreleased changelog entry documenting the change and the
.nodeenvcleanup 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 Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #445 +/- ##
=======================================
Coverage ? 56.30%
=======================================
Files ? 2
Lines ? 547
Branches ? 0
=======================================
Hits ? 308
Misses ? 239
Partials ? 0
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
🎭 Visual Regression Test ResultsDetails
Skipped testsdesktop-chrome › theme.spec.ts › Visual Regression Tests › prob-matrix - full page screenshot |
99ee5ce to
7974131
Compare
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]>
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-nodestep and.nvmrcalready say 24.Why the workflows' Node 24 was not enough
pyproject.tomlpinsnode-versionunder[tool.sphinx-theme-builder]. sphinx-theme-builder (0.3.2, which the>= 0.2.0a7build requirement resolves to) runspython -m nodeenv --node=<pin> --prebuiltto install exactly that Node into.nodeenv/, and that Node runsnpm install --include=devandnpm 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, whateversetup-nodesaid:tests.ymlpublish(v* tags)python -m build, the wheel published to PyPItests.ymltestspip install -e .[test]ci.ymlbuildpip install ., the theme the fixtures site and Playwright tests usedocs.ymlbuildpip install -e .[doc], which rebuilds the assets over thenpm run buildbefore itupdate-snapshots.yml, both jobspip install .of the PR branch, before regenerating baselinespip install -e .,tox,stb compile#401 moved the
setup-nodesteps and.nvmrcto 24 but not this line, and #441 did not touch it.What changes
pyproject.toml[tool.sphinx-theme-builder]node-version20.18.024.21.0.nvmrc2424.21.0docs/developer/setup.md, troubleshooting.nvmrcmoves with the pinCHANGELOG.md24.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 --versionfrom.nodeenv/with it and stops withnodeenv-version-mismatchon any difference, so a bare24cannot work here..nvmrcfollows the pin exactly. quantecon-sphinx-theme set its.nvmrcto the same24.21.0as itspyproject.toml, and this does the same. No workflow here reads.nvmrc; it is whatnvm usereads for local development. With24, nvm takes the newest 24.x installed, so runningnpm run buildor 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 runnvm installonce per bump, sincenvm useonly switches to a version already installed. quantecon-sphinx-theme#9 accepted the same trade-off.The
setup-nodesteps stay at'24'. Inci.yml(visual) andupdate-snapshots.ymlthey run onlynpm ciand Playwright. Indocs.ymlthe editable install that followsnpm run buildrecompiles the assets on the nodeenv's Node. So none of them builds an asset that ships. On this PR'svisualjob,'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 itsdocs.ymltonode-version-file: .nvmrcafter review. That would also work here, butdocs.ymlruns only onmainandupdate-snapshots.ymlonly from the default branch, so this PR's CI could not test it. I have left it for a separate decision.Compatibility:
create_nodeenvpasses the pin straight to nodeenv, and nothing in it depends on the Node major.node-v24.21.0-linux-x64.tar.gzandnode-v24.21.0-darwin-arm64.tar.gzboth return HTTP 200 from nodejs.org.node-v24.21.0-linux-armv7l.tar.gzandnode-v24.21.0-win-x86.zipreturn 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. Thepy3-none-anywheel on PyPI is unaffected, and its contents are byte-identical (below). 90b899f adds this and thenvm installnote to the CHANGELOG entry.package.jsonhas noenginesfield. Seven dev dependencies need a newer Node than 20.18.0, and the 20.18.0 build printed anEBADENGINEwarning 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 buildbuilds the sdist and then the wheel from it, as thepublishjob does, andpip wheel .builds in the tree, asci.ymlandtests.ymlinstall. Both builds used sphinx-theme-builder 0.3.2.main--node=20.18.0,node --versionv20.18.0, npm 10.8.2--node=24.21.0,node --versionv24.21.0, npm 11.19.0npm install --include=devEBADENGINEwarningsdiff -ron the unpacked wheels, both build routes)The compiled
quantecon-book-theme.css(sha2566ceb0664…),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.jsonis unchanged after npm 11'snpm install, and the two sdists differ only inpyproject.toml. On macOS, npm 11.19.0 also prints aninstall-scriptsnotice 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 atnodeenv-version-mismatchon the nexttoxorpip 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. Runningrm -rf .nodeenvclears 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):
pre-committests, Python 3.12 and 3.13 with Sphinx 7 and 8 (4 jobs)build(fixtures site,jb build . --warningiserror)visual(Playwright)preview, Netlify, codecov/patch, codecov/projectPublish to PyPiWhich 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
mainor here. To get it into a log, I pushed a temporary commit, 99ee5ce, which added-vto thepip installinci.ymlbuildand intests.ymltests. 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 fixturesbuildand the fourtestsjobs) 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'snode --versioncheckadded 438 packages, and audited 439 packages, with nonpm warnorEBADENGINEline, thenwebpack 5.108.3 compiled successfullyand[stb] Done!A green build implies the pin even without those lines. sphinx-theme-builder stops with
nodeenv-version-mismatchunlessnode --versionequals the pin exactly, and no workflow setsSTB_RELAX_NODE_VERSION_CHECKorSTB_USE_SYSTEM_NODE.Compiled output. The
fixtures-buildartifact from 35344279392 (91 files) is byte-identical to the one from themainpush 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.jsand 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.ymlpublishruns only on v* tags. The localpython -m buildcomparison above follows the same route and gave identical wheels, but the first PyPI build on 24.21.0 will be the next release.docs.ymlruns only on push tomainand onworkflow_dispatch, so its first run on the new pin will be the merge.update-snapshots.ymlruns only on an/update-snapshotscomment, and nobody ran it on this PR. It builds withpip install .from the PR branch, so it takes whichever pin that branch carries.🤖 Generated with Claude Code