Skip to content

feat: npm-tier example with no server JS and no config tag (#261) - #263

Merged
schloerke merged 1 commit into
mainfrom
schloerke/faithful-no-jsdep-example
Sep 11, 2026
Merged

schloerke merged 1 commit into
mainfrom
schloerke/faithful-no-jsdep-example

Conversation

@schloerke

@schloerke schloerke commented Aug 31, 2026 •

Copy link
Copy Markdown
Collaborator

examples/11-npm-local is the Old Faithful app (app.py + app.R over one client) at the npm tier with nothing else on the page.

#264 gave npm-tier apps shinyreact_js="client", which omits shinyreact.js but still emits the #shinyreact-config tag. This app needs neither, so its whole page is:

ui = page_bare(page_react_dep(src_dir=_APP_DIR / "www", name="npm-local"))
  • no shinyreact.js — one React and one hook registry on the page
  • no config tag, so no protocol handshake — nothing on the page is versioned separately from the app that shipped it

The client imports @posit/shinyreact from the repo-relative file:../../pkg-js placeholder, same as examples/09-hmr, until the first npm publish.

The deletion

The config-tag strict mode is gone. It made a missing tag — or a tag with no protocolVersion — throw rather than log, but only in the npm build, on the reasoning that an independently installed client meeting a tagless page means the server predates the protocol. It also banned the simplest page there is. With nothing opting in, requireShinyReactConfigTag(), isShinyReactConfigTagRequired(), the flag and the test-only reset are removed, along with the two branches in bookmark.ts and examples/testing/mount.ts's reset call.

Unchanged: a major-version mismatch still throws visibly in both builds, and a tag with no protocolVersion still logs an error. #264's double-load warning is untouched.

Docs corrected where they justified the tag by the old behavior — page_react() / page_react_html() / set_react_page() / ReactApp() (py + R + page_react.Rd), _dep.py / dep.R, FEATURES.md: the tag is still emitted under shinyreact_js="client", but because it carries the protocol version and any bookmark restore payload, not because the client hard-errors without it.

Verification

vitest 277 passed
pytest 161 passed
testthat 270 passed
pyright / tsc / ruff / prettier clean

Plus the app itself, driven in a browser on the Python server: page carries no shinyreact.js and no config tag, slider → server → SVG round-trips, no console errors.

Note on scope

An earlier revision of this PR shipped pkg-js/dist-npm/ inside the wheel and inst/ so an app could install @posit/shinyreact from .venv / renv (#261's actual proposal). That worked — portable lockfile, one symlink resolving for both languages — but it is not in this PR; the example uses the repo-relative placeholder instead, and #261 keeps the question. The evidence is recorded in a comment there.

@schloerke
schloerke force-pushed the schloerke/faithful-no-jsdep-example branch from 83b244f to 2c77aa6 Compare August 31, 2026 14:56
@schloerke
schloerke force-pushed the schloerke/faithful-no-jsdep-example branch 2 times, most recently from 2b9ca8e to 80d7661 Compare August 31, 2026 16:42
@schloerke

Copy link
Copy Markdown
Collaborator Author

Rebased onto main now that #264 has landed. How the semantic conflict it flagged was resolved:

Verified after the rebase: vitest 280, pytest 161, testthat 270, pyright/tsc clean, and examples/11-npm-local re-run in a browser on the Python server — page still carries no shinyreact.js and no config tag, and no double-load warning fires.

@schloerke
schloerke force-pushed the schloerke/faithful-no-jsdep-example branch from 80d7661 to 3c5cd84 Compare August 31, 2026 16:52
@schloerke schloerke changed the title feat: an example that installs the npm client from the server package (#261) feat: npm-tier example with no server JS and no config tag (#261) Aug 31, 2026
@schloerke
schloerke marked this pull request as draft September 10, 2026 20:14
@schloerke
schloerke force-pushed the schloerke/faithful-no-jsdep-example branch 3 times, most recently from 5f7e949 to fb489f9 Compare September 11, 2026 20:18
examples/11-npm-local is Old Faithful (app.py + app.R over one client) at the
npm tier with nothing else on the page. Where examples/09-hmr uses
`set_react_page(shinyreact_js="client")` — which omits the JS but still emits
the `#shinyreact-config` tag — this app's whole page is
`page_bare(page_react_dep(...))`, so it has:

- no shinyreact.js, hence one React and one hook registry on the page;
- no config tag, hence no protocol handshake.

The client imports `@posit/shinyreact` from the repo-relative
`file:../../pkg-js` placeholder, the same one 09-hmr uses until the first npm
publish.

The second half is a deletion. The config-tag strict mode — a missing tag, or
a tag with no `protocolVersion`, throwing rather than logging — existed only
for the npm build, on the reasoning that an independently installed client
meeting a tagless page means the server predates the protocol. It also banned
the simplest page there is. Nothing opts into it now, so
`requireShinyReactConfigTag()`, `isShinyReactConfigTagRequired()`, their flag
and their test-only reset are gone, along with the two branches in
bookmark.ts. A tag with no `protocolVersion` still logs; a major-version
mismatch still throws visibly, in both builds.
@schloerke
schloerke force-pushed the schloerke/faithful-no-jsdep-example branch from fb489f9 to adce7ff Compare September 11, 2026 20:30
@schloerke
schloerke marked this pull request as ready for review September 11, 2026 20:36
@schloerke
schloerke merged commit 8ef4149 into main Sep 11, 2026
21 checks passed
@schloerke
schloerke deleted the schloerke/faithful-no-jsdep-example branch September 11, 2026 20:42
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.

1 participant