Skip to content

Load one Lit: vendor/lit.js, shared by the framework and Web Awesome - #1011

Merged
max-sixty merged 4 commits into
mainfrom
one-lit
Sep 23, 2026
Merged

max-sixty merged 4 commits into
mainfrom
one-lit

Conversation

@max-sixty

@max-sixty max-sixty commented Sep 23, 2026 •

Copy link
Copy Markdown
Owner

Every page evaluated Lit twice. scripts/browser/build.mjs bundled it into browser-runtime.js, and vendor.py's Web Awesome build bundled it again into the shared chunk every page loads through webawesome-chrome.js. In a served page window.litHtmlVersions read ["3.3.3", "3.3.3"], and the same for litElementVersions and reactiveElementVersions. That meant two LitElement classes, two template caches, and a Lit pin in two files (package.json, vendor.py PINS) that could drift apart.

Change

  • The browser build now also writes skills/leaf/assets/vendor/lit.js. It holds every public Lit module in one namespace, shaped like Lit's own lit-all bundle: static-html's tags are exported as staticHtml, staticSvg and staticMathml, so they don't shadow the ordinary tags. The list of modules comes from Lit's package.json exports, so nothing is maintained by hand. browser-runtime.js imports Lit from ./lit.js.
  • The Web Awesome build externalizes every lit specifier to /vendor/lit.js and maps lit/static-html.js onto the renamed tags. It no longer bundles or pins Lit. It installs package.json's lit beside Web Awesome and refuses to build if npm has to nest a different Lit under Web Awesome, so the one pin still has to fall inside Web Awesome's declared range.
  • scripts/vendor.py --pins also reads the package.json pins that the browser build's manifest lists as page payload (lit and @preact/signals-core). It still holds lit to Web Awesome's range and names browser (npm run build:browser) as the rebuild, so Lit keeps its weekly drift row without a second pin. The running-tend weekly step and the dependabot.yml comment describe this.
  • Before, the build gate refused every import in browser output. It now admits a static import of a sibling output and nothing else. build.test.mjs checks that the framework imports ./lit.js instead of carrying Lit, and that lit.js exports the names Web Awesome uses.

Measured

I served the heat-loss preview from each checkout and ran the same journey on both, reading performance.getEntriesByType('resource') and the version globals:

main this branch
litHtmlVersions ["3.3.3","3.3.3"] ["3.3.3"]
vendor requests 6 7 (+lit.js)
boot bytes (runtime + WA chunk [+ lit.js]) 287,141 282,842

Neither console logged errors. wa-input and wa-copy-button upgrade.

Tests

  • npm run test:browser and npm run check:browser
  • npm run test:runtime
  • pytest --run-nightly tests/test_interact_document.py tests/test_render_export.py tests/test_interact_layer.py
  • tests/test_render_widgets.py -k "webawesome or color or slider or switch or radio or select or number or textarea or comparison or copy"
  • pre-commit

This was written by Claude Code on behalf of max-sixty

🤖 Generated with Claude Code

Two generators each bundled Lit: scripts/browser/build.mjs into
browser-runtime.js, and vendor.py's Web Awesome build into its shared chunk.
Every page therefore evaluated Lit twice (window.litHtmlVersions read
["3.3.3", "3.3.3"]): two LitElement classes, two template caches, and two
pins in two files that could drift apart.

The browser build now writes vendor/lit.js, every public Lit module in one
namespace in the shape of Lit's own lit-all bundle (static-html's tags as
staticHtml, staticSvg, staticMathml), and binds the framework's Lit imports
to it. The Web Awesome build externalizes every lit specifier to
/vendor/lit.js, mapping static-html onto the renamed tags, and no longer
bundles or pins Lit; it installs package.json's lit beside Web Awesome and
refuses when npm has to nest a different one under it, so the single pin
still has to fall inside Web Awesome's declared range.

The build gate that refused every import in browser output now admits a
static import of a sibling output and nothing else. build.test.mjs checks
the framework imports ./lit.js rather than carrying Lit, and that lit.js
exports the names Web Awesome reaches for.

Served heat-loss preview, same journey: litHtmlVersions ["3.3.3","3.3.3"]
-> ["3.3.3"], vendor requests 6 -> 7 (lit.js), boot bytes for
browser-runtime + Web Awesome chunk (+ lit.js) 287,141 -> 282,842.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Removing lit from scripts/vendor.py's PINS leaves its version with no drift watcher. report_pins iterates PINS, so scripts/vendor.py --pins — the weekly step that exists because these versions "drift silently" — no longer prints a lit row, and .github/dependabot.yml declares only the github-actions and uv ecosystems, so nothing reads package.json either. The new refusal in build_webawesome is a different guard: it fires on a bump that lands outside Web Awesome's range, and a Lit that simply never moves produces no signal at all.

The gap is wider than lit. package.json now holds the framework's whole browser payload pin set — lit and @preact/signals-core both reach a page — and no watcher reads it. @preact/signals-core was already sitting there, so this PR isn't what opened the hole, but it moves the page's single most consequential browser dependency into it without saying so.

Both homes for the fix have a cost, so it's a call for you rather than something to just push: an npm entry in .github/dependabot.yml would cover package.json and pick up @preact/signals-core too, but esbuild is pinned in both PINS and devDependencies, so dependabot would move one copy and leave the other disagreeing; a lit row back in PINS would reinstate the two-places-to-drift problem this PR set out to remove. Say which and I'll push it.

Lit left PINS when the Web Awesome bundle stopped carrying it, which took
its row out of the weekly drift report; @preact/signals-core, also page
payload, never had one. --pins now also reads the package.json pins the
browser build's manifest lists as bundled, holds lit to Web Awesome's
range as before, and names npm run build:browser (plus webawesome for
lit) as the rebuild. The pins stay in package.json alone.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@max-sixty

Copy link
Copy Markdown
Owner Author

Pushed 7a1e846 for the drift gap without a second pin: vendor.py --pins now also reads the package.json pins that the browser build's manifest lists as bundled page payload (lit, @preact/signals-core). lit is still held to Web Awesome's range, and the rebuild column names browser (plus webawesome for lit). I left dependabot's npm ecosystem alone because of the esbuild double pin you pointed out.

This was written by Claude Code on behalf of max-sixty

@leaf-agent

Copy link
Copy Markdown
Collaborator

Confirmed — both rows are back and neither reinstates a second place to drift. scripts/vendor.py --pins on 7a1e846 ends with:

@preact/signals-core   1.14.4     browser
lit                    3.3.3      browser webawesome

lit keeps the holder semantics PINS gave it: npm view @awesome.me/[email protected] dependencies.lit returns ^3.2.1, and 3.3.3 is the newest release inside that range, which is why the row prints no movement rather than no range. Reading bundledDependencies out of the build manifest and intersecting it with devDependencies is what keeps the transitive lit-html/lit-element/@lit/reactive-element entries from each becoming their own row, and esbuild — contributorDependencies, not bundled — still reports once from PINS. Leaving dependabot's npm ecosystem out given the esbuild double pin is the right call; my review raised that as the cost of the other option, not as something to pay.

Separately, and not about the diff: ci has no run on 7a1e846. tend-review fired on that push at 16:38:36Z, but the pull_request synchronize produced no ci run alongside it, and gh pr checks 1011 --required reports no required checks on the branch — the green ci on this PR is still d2c2140's, one commit behind. A workflow_dispatch won't stand in, because lint and test are both gated to pull_request/push in ci.yaml and nightly needs them, so a dispatched run on a branch has nothing to do. Another push or a close/reopen is what puts the gate on this head.

For the interim I ran the gate's Python half over the commit's only non-doc file: ruff check and ruff format --check on scripts/vendor.py both pass, and the --pins output above is the code actually executing.

What I checked and how
  • ./scripts/vendor.py --pins from a checkout at 7a1e846 — full run against the live npm registry, both new rows present, no duplicate esbuild.
  • python3 -c over scripts/browser/generated/browser-runtime.manifest.json: bundledDependencies is {@lit/reactive-element, @preact/signals-core, lit, lit-element, lit-html}; the if package in pinned filter in browser_pins() reduces it to the two devDependencies entries.
  • gh api "repos/max-sixty/leaf/actions/runs?branch=one-lit" at 16:42Z and 16:43Z — tend-review on 7a1e846, ci only on d2c2140. Pushes to reach-drag and frozen-move-receipts in the same window each created ci and tend-review together, so the workflow is not disabled; I have not found the mechanism for this one push.

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

scripts/AGENTS.md still says of vendor.py that "Every pinned version sits in one table there", and this PR makes that false: lit's pin moved to package.json, and build_webawesome installs it from there — lit = browser_pins()["lit"], then f"lit@{lit}" in the npm install. That fact has three copies in the tree, and 7a1e846 corrected the other two, the dependabot.yml comment and the weekly step. This is the one a session reads before touching vendor.py, so the reader who comes to bump Lit looks in PINS, doesn't find it, and has nothing pointing at package.json.

The sentence sits outside the diff's hunks, so I can't attach a suggestion. Replacing it with something like:

Every version it pins sits in one table there, except the page payload the browser build bundles — lit and @preact/signals-core, pinned in package.json and read from the build manifest by --pins.

would close it. Say the word and I'll push it.

max-sixty and others added 2 commits September 23, 2026 09:56
# Conflicts:
#	scripts/browser/generated/browser-runtime.js.map
#	scripts/browser/generated/browser-runtime.manifest.json
#	skills/leaf/assets/vendor/browser-runtime.js
@max-sixty

Copy link
Copy Markdown
Owner Author

db7bb4b rewrites that scripts/AGENTS.md sentence to say that Lit and Signals are pinned in package.json and that --pins reads them there. cb65b3d merges main and regenerates the browser outputs.

This was written by Claude Code on behalf of max-sixty

@leaf-agent

Copy link
Copy Markdown
Collaborator

db7bb4b closes the scripts/AGENTS.md finding — the sentence now splits the two homes, so all three copies of that fact agree.

And the mechanism for the missing ci run is found: the branch had a merge conflict with main, and GitHub does not run pull_request workflows on a conflicted PR — "Workflows will not run on pull_request activity if the pull request has a merge conflict… Conversely, workflows with the pull_request_target event will run even if the pull request has a merge conflict." ee2f3ff1 landed on main at 16:09Z and regenerated the same three files this branch regenerates, so from that point the branch head did not merge:

$ git merge-tree --write-tree 7a1e8463 ee2f3ff1
CONFLICT (content): Merge conflict in scripts/browser/generated/browser-runtime.js.map
CONFLICT (content): Merge conflict in scripts/browser/generated/browser-runtime.manifest.json
CONFLICT (content): Merge conflict in skills/leaf/assets/vendor/browser-runtime.js

Same three for db7bb4b5 against 0d96fe53. That accounts for every run on the branch: d2c21402 (15:42Z, before ee2f3ff1) got both ci and tend-review; 7a1e8463 and db7bb4b5 got only tend-review, which is pull_request_target; cb65b3de resolved the conflicts and ci 35892355902 started 7s after that push. So the remedy I named last time was wrong — another push would have been skipped the same way, and merging main is what put the gate back on the head.

Worth naming above this PR: committed generated browser output means any two branches that regenerate it conflict, and the consequence is not just a merge to do — the conflict silently removes the only required check from the head while the PR keeps showing a green ci from an older commit. This PR adds a fourth such output (lit.js and its map), so it widens that slightly. Nothing to change here, since nothing is built at install time and the payload has to be committed; it is the --pins-style gap one layer down, in CI rather than in versions.

cb65b3de's regenerated outputs are self-consistent: every outputs entry in browser-runtime.manifest.json matches the committed file's byte count and sha256, and browser-runtime.js still imports LitElement/html/nothing/render and repeat from ./lit.js. lint is green on that head and test is still running as I write this.

@max-sixty
max-sixty merged commit 0e2da78 into main Sep 23, 2026
5 checks passed
@max-sixty
max-sixty deleted the one-lit branch September 23, 2026 17:18
max-sixty added a commit that referenced this pull request Sep 24, 2026
… its lock (#1084)

JS versions lived in two manifests. `scripts/vendor.py` kept a `PINS`
table and installed each bundle's packages into a throwaway npm
directory. The browser framework build pinned Lit, Signals and esbuild
in `package.json`, and #1011 and #1022 moved rows across one at a time.
`plot`, `pierre` and `mcp-app` also took their transitive dependencies
from whatever npm resolved on the day, so their bytes weren't
reproducible.

Now `package.json` pins every package a bundle's own source imports, and
`package-lock.json` settles the rest of each closure. `vendor.py` builds
every bundle from the root `node_modules` that `npm ci` installs and
reads banner versions from there. `PINS`, the throwaway installs,
`HELD_BY`, `REBUILDS` and `--pins` are gone. A package that another
package depends on is now held by that dependant's range and the lock,
which is what `HELD_BY` used to approximate.

**Testing the model.** First I added every existing pin to
`package.json`, and all of them resolved in one tree without conflict.
Nested copies exist (`marked` 11 under Web Awesome, `acorn` under
agentic-mermaid, `entities` 6 under parse5), but none of them reaches a
bundle differently than it did before. Rebuilding from the root lock
reproduced every tracked file byte for byte. The one exception is the
Web Awesome shared chunk's name (`chunk-SH2BVOI3.js` →
`chunk-DGEFCNBY.js`): esbuild's chunk hash covers input paths, and the
content is identical. That new name is stable across runs. Then I
trimmed `package.json` to direct imports only, and the lock kept every
resolved version.

**What moved:**
- CI's `test` job runs `uv run scripts/vendor.py` and fails on any diff,
now that a rebuild reproduces exactly. Root `AGENTS.md` says `wt merge`
doesn't run this check.
- Dependabot now watches the root npm manifest, grouped weekly, with
esbuild excluded. Its PR stays red until the bundles are rebuilt, and
running-tend's weekly section says how.
- `browser-runtime.manifest.json` records the lock hash and contributor
dependencies, so it was regenerated.
- Deleted `test_the_tooling_instructions_place_every_vendored_bundle`,
since the reproducible/unreproducible split it enforced no longer
exists. The MCP App banner test reads the lock.
- Pierre's license walk resolves each package to the copy esbuild
actually read, nested or not.

**Verification:** `npm ci`; `npm run check:browser && npm run
test:browser` (64 pass); `npm run test:runtime` (91 pass); `uv run
scripts/vendor.py` twice with a clean tree; `uv run pytest tests` (1353
passed).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
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