Repository navigation
fix(author): the command line as one file prints its versions - #199
Merged
Merged
Conversation
The site serves the command line bundled into one file, h5p-author.mjs, and its --version crashed: it read this package's package.json and the pack's as files, and neither is beside the one file. Each version is now also a JSON import, which the bundler writes into the file. The files are still read first where the packages are installed, since Node before 22.12 warns on a JSON import, and a package.json above the one file that is not this package's is passed over.
Contributor
There was a problem hiding this comment.
No issues found across 3 files
Tip: cubic could auto-approve low-risk PRs like this, if it thinks it's safe to merge. Learn more
View guided diff | Turn on auto-fix | Re-trigger cubic
This was referenced Nov 13, 2026
Closed
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.
Closes #198.
What changes
bin/h5p-author.mjs:--versiontakes this package's version fromownVersion(). It reads../package.jsonas before, but only if that file names this package. Otherwise it usesimport('../package.json', { with: { type: 'json' } }).lib/node.mjs:packVersion()reads the libraries package'spackage.jsonas before, and falls back to the same kind of import.Where the package is installed from npm, the files are read and nothing changes. The site's Vite bundles the command line into one file, and there it writes both imports into the file, so the single file carries its versions.
The file is read first because Node before 22.12 warns on every JSON import: "ExperimentalWarning: Importing JSON modules is an experimental feature", checked on Node 22.11. A model reading the output could take that warning as a fault.
design/author.md: the bundle rule records the crash and the fix.Checked
test:unitpasses, 183 tests, including the existing-vtest, andtypecheckpasses.--versionand a build print the same as before on Node 22.11.0 and 23.11.1, with no warning on 22.11.main(pin 0.9.7), and ranpnpm build. The resultingh5p-author.mjs:@missing-elements/h5p-author 0.9.7, library pack 1.1.0alone in an empty folder, on Node 22.11 and 23.11, where the live file crashes;package.json;H5P.QuestionSet.zipwith--libraries parts, and the package plays in the verifier.package.jsonobjects are written into it.Not covered by a test here: only a bundler produces the single file, and this package has none. After the release, the site's pin bump can check it at build time: run the bundled tool's
--versionand compare it with/h5p/bundles/index.json. The comment in the site'svite.config.tsthat says the tool cannot read its versions changes then too.Summary by cubic
Fixes
--versioncrashing when the command line is bundled into a single file, as the site serves it.package.jsonand the pack's from disk, neither of which sits beside it.Written for commit dc5bc35. Summary will update on new commits.