Skip to content

fix(libraries): keep an unchanged library's entries from the pack before (#116) - #118

Merged
alekswebnet merged 1 commit into
mainfrom
fix/pack-unchanged-parts
Nov 2, 2026
Merged

alekswebnet merged 1 commit into
mainfrom
fix/pack-unchanged-parts

Conversation

@alekswebnet

Copy link
Copy Markdown
Contributor

Closes #116.

What

  • writePack in packages/libraries/scripts/parts.mjs writes the pack: its h5p.json, then each library's files. A library whose files are byte for byte those its folder holds in the committed pack keeps that pack's entries as they are, their order and compressed bytes included, as splitPack already copies entries into the parts. Its part then comes out as before, whatever order the hub's bundle lists its files in now.
  • build-libraries.mjs writes the pack with it, passing the committed libraries.h5p.
  • The Library pack workflow stops when a part changes and its library's line in libraries.txt does not. The guard it had stops only a rebuild in which no library changed at all.

The other fix, sorting every library's files by name, is one line. But it would rewrite every part once, so every package the pack serves would get a new revision and start its saved state over one more time.

Checked

  • The real case: with the fix, pnpm libraries --refresh from today's hub changes the parts of the five updated libraries alone (Branching Scenario, Components, Flashcards, Memory Game and Question Set), and libraries.txt the same five lines. Each of those parts is byte for byte the one Library pack 1.0.1 #111 has. Library pack 1.0.1 #111, built from the same hub without the fix, has 35. The regenerated files are not in this PR: the workflow writes them again.
  • Nothing changes without a reason: the committed pack, rebuilt from its own files with every library's files in reverse order, comes out byte for byte (13,692,496 bytes), and so do its 105 parts and index.json. Without the committed pack, the same files give another pack.
  • Tests: pack-bytes.test.ts covers both cases: a library listed in another order keeps its entries, and only a changed library's part gets a new hash. With the reuse turned off, both tests fail. The time-zone test now writes its pack with writePack too. The player's unit suite passes (366), and so does its typecheck.
  • The guard: run in bash as the workflow runs it, it stops on Library pack 1.0.1 #111's files, naming the 30 parts, and lets the five updated parts through.
  • pnpm parts still reproduces the committed parts.

After merging

Run the Library pack workflow from the Actions tab, or with gh workflow run libraries.yml. It force-pushes libraries/refresh from main, and #111 then holds the five updated libraries alone. CI starts on #111 after a push to its branch, or after closing and reopening it.

🤖 Generated with Claude Code

…ore (#116)

The refresh that opened #111 rewrote 30 parts whose libraries had not
changed: the build takes each library from the first hub bundle that
carries its newest version, in that bundle's order, and the hub had
rebuilt Branching Scenario's bundle, the first to carry them, with
their files in another order. A part's id is its hash and the libraries
revision covers entry order, so every browser would download those
parts again and every package played with them would get a new revision.

writePack in packages/libraries/scripts/parts.mjs writes the pack, and a
library whose files are byte for byte those its folder holds in the
committed pack keeps that pack's entries as they are, as splitPack copies
entries into the parts. build-libraries.mjs writes the pack with it. The
library pack workflow also stops when a part changes and its library's
line in libraries.txt does not.

Rebuilt from today's hub, the pack changes the five updated libraries'
parts alone, each byte for byte the part #111 has. The committed pack,
rebuilt from its own files in reverse order, comes out byte for byte.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@alekswebnet
alekswebnet merged commit 4340cdc into main Nov 2, 2026
9 checks passed
@alekswebnet
alekswebnet deleted the fix/pack-unchanged-parts branch November 3, 2026 11:11
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.

Library pack refresh rewrites parts whose libraries did not change

1 participant