fix: version the shinyreact HTMLDependency by the JS package version - #308
Merged
Merged
Conversation
schloerke
force-pushed
the
schloerke/dep-js-version
branch
from
September 12, 2026 22:58
50e942a to
48f4f51
Compare
schloerke
enabled auto-merge (squash)
September 12, 2026 22:58
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The shinyreact dependency was versioned by the bundle file's mtime, so a page loaded:
A number that says nothing about which
@posit-dev/shinyreactrelease is on the page. Now that the package is published, use its version:Beyond being readable, this is checkable: an npm-tier app bundles its own copy of the runtime, and the page source now says which release the server is serving, so a version skew between the two is visible rather than inferred.
How the version gets there
make update-distwritespkg-js/package.json's version to a one-lineversion.txtbeside the bundle, in both packages — same committed-copy flow as the bundle itself._bundle_version()(Python) and.bundle_version()(R) read it.The fallback chain, and why it kept the mtime
version.txt→ bundle mtime → per-language last resort.The mtime is demoted rather than deleted on purpose. It existed to cache-bust the browser after a
make update-dist, and in a dev checkout that still matters: severalupdate-distruns share one npm version, so a pure-version scheme would serve a stale cached bundle after a rebuild. Keeping mtime as the fallback covers the partially-built case, but note the tradeoff this PR does accept — in a normal checkoutversion.txtis present, so between releases repeatedmake update-distruns now produce the same URL and a browser may serve a cached bundle until a hard refresh. If that bites,0.1.1+<mtime>is a one-line change that restores busting while keeping the release legible; say the word.A blank
version.txtis treated as absent, not as an empty version — otherwise htmltools would build/lib/shinyreact-/.The last-resort fallbacks are untouched, including their deliberate divergence:
[py]the literal"0.1.0",[r]packageVersion("shinyreact").Not touched
page_react_dep()— the app's bundle — still versions byui.js's mtime. That is the cache-busting-during-development case the mtime scheme was designed for, and an app author's bundle has no npm version to use.Tests
Six new/rewritten, three per language, mirrored and cross-referenced by name per the both-languages rule:
test_dep_version_is_the_js_package_versionversion.txt→ mtimetest_dep_version_falls_back_to_mtime_without_version_fileversion.txt→ mtimetest_dep_version_ignores_an_empty_version_filemake py-check-tests199 passed ·pyright0 errors · full testthat suite passes · wheel build confirmsshinyreact/www/version.txtships (it is inside the hatchling package dir;inst/lib/shiny/covers R).FEATURES.md's "Asset delivery" leaves updated, with(test)markers on the three pinned claims.