Skip to content

feat(author): build the one-file tool in the package, not on the organisation's site - #250

Merged
alekswebnet merged 2 commits into
mainfrom
feat/author-one-file-tool
Nov 19, 2026
Merged

alekswebnet merged 2 commits into
mainfrom
feat/author-one-file-tool

Conversation

@alekswebnet

@alekswebnet alekswebnet commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Closes #247.

Route 3 runs h5p-author.mjs, the command line as one file. Until now the organisation's site built that file with its own Vite when it built itself. So the site's build tools and their Dependabot updates were in the path of every byte a chat runs, and nothing published covered the file. With this PR, the author package builds the file and ships it, so the npm package covers it, and its provenance will once #246 is in. From the first release that ships it, the site's pin copies it instead of building it.

What changes

  • scripts/build-tool.mjs builds dist/h5p-author.mjs and dist/h5p-author-LICENSES.txt. Its Vite build is the site's, unchanged: a server-side build of bin/h5p-author.mjs, everything bundled in, not minified, one file, with Vite's licence list. It then checks that the tool's --version names this package's version and its pack's. node scripts/build-tool.mjs <folder> writes the two files elsewhere.
  • package.json:
    • build:tool builds the player's plan, which the tool imports, then runs the script.
    • prepack ends with it.
    • files gains dist.
    • Vite 8.3.8, the player's and the site's version, becomes a devDependency. The lockfile gains its three importer lines and nothing else.
    • exports names the two files, ./dist/h5p-author.mjs and ./dist/h5p-author-LICENSES.txt, so they resolve by the package's name.
  • Node: packing on Node before 22.12 stops with a message before Vite fails to load. The package's engines stays >=22, since installing it runs none of this, and raising it would make an unversioned npx on Node 22.0 to 22.11 quietly install an older release.
  • Comments: ownVersion and packVersion no longer say the site builds the file.
  • Docs:
    • design/author.md has a new rule with its reason: when the site switches, why packing needs Node 22.12 while engines stays, and why the skill names no hash of the file.
    • The tool's size is now 756 kB, up from the 575 kB the design file gave.
    • The author README and design/layout.md name the two files and the script.

Tested

  • The new test builds the tool into a temporary folder, unzips a Question Set bundle where no package.json is above and nothing is installed, as a chat's sandbox has it, and checks two things:

    • The tool prints both versions from the copies bundled into it.
    • It builds a quiz with --libraries parts.

    It also checks that the licence list names zip.js under BSD-3-Clause, and resolves both files by the package's name through exports.

  • Suites: pnpm typecheck and the author's node suite (266 tests) pass.

  • The packed package: pnpm pack ran prepack through to the tool. The tarball holds the two files (94 entries, 383 kB packed), and its tool, extracted alone, prints @missing-elements/h5p-author 0.13.0, library pack 1.1.0.

  • Sizes: the tool is 756 kB, 213 kB gzipped. The package grows from 0.60 MB unpacked to about 1.36 MB.

After the next release

The site's pin PR replaces its Vite build of the tool (bundles() in vite.config.ts) with a copy of the two files from node_modules/@missing-elements/h5p-author/dist/, and keeps its --version check. Until then it builds the tool as before, from 0.13.0, which does not ship it.


Summary by cubic

Closes #247. The author package now builds the one-file command-line tool and ships it in dist/, so the npm package covers the bytes route 3 runs and the organisation's site will serve the file as shipped instead of building it with its own Vite.

  • scripts/build-tool.mjs bundles the command line and everything it imports into dist/h5p-author.mjs, writes dist/h5p-author-LICENSES.txt beside it, and checks that --version names this package's and its pack's versions; prepack runs it.
  • The two files are exported by their paths, and a test resolves them by the package's name.
  • Packing on Node before 22.12 stops with a message before Vite fails to load; engines stays >=22 since installing runs none of this.
  • The tool is 756 kB (213 kB gzipped); the packed package grows from 0.60 MB to about 1.36 MB unpacked.
  • A new test builds the tool and runs it from an unzipped bundle with nothing installed, as a chat's sandbox has it.

Migration
After the next release, the site's pin PR replaces its Vite build of the tool with a copy of the two files from node_modules/@missing-elements/h5p-author/dist/ and keeps its --version check; until then it builds from 0.13.0, which does not ship them.

Written for commit 4c36491. Summary will update on new commits.

View guided diff Turn on auto-fix

…nisation's site (#247)

prepack runs scripts/build-tool.mjs: Vite bundles the command line and
everything it imports into dist/h5p-author.mjs, with dist/h5p-author-LICENSES.txt,
as the site's own build did, and checks its --version. The npm package then
covers the bytes route 3 runs, with its provenance once publishing moves to CI,
and the site serves them as shipped.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 9 files

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread design/author.md Resolved
Comment thread packages/author/README.md Resolved
Comment thread packages/author/package.json Resolved
Comment thread packages/author/package.json Resolved
Comment thread packages/author/lib/node.mjs Resolved
…e site serves when (#247)

The two dist files are exported by their paths, and a test resolves them by the
package's name. Packing on Node before 22.12 stops with a message before Vite
fails to load; engines stays >=22, since installing runs none of it. The design,
the README and the comments no longer say the site serves the shipped file
already: its pin copies it from the first release that ships it.
@alekswebnet
alekswebnet merged commit 3ef8a6c into main Nov 19, 2026
14 checks passed
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.

h5p-author: build the one-file tool in the package, not on the organisation's site

1 participant