Skip to content

Commit 19dc77d

Browse files
authored
Merge pull request #79 from missing-elements/deps/h5p-author-0.14.0
Pin h5p-author 0.14.0, and copy the build tool from the author package
2 parents 35e0554 + 920b7c1 commit 19dc77d

3 files changed

Lines changed: 24 additions & 59 deletions

File tree

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"@codemirror/state": "6.7.6",
2929
"@codemirror/view": "6.43.15",
3030
"@lezer/highlight": "1.2.5",
31-
"@missing-elements/h5p-author": "0.13.0",
31+
"@missing-elements/h5p-author": "0.14.0",
3232
"@missing-elements/h5p-libraries": "1.1.1",
3333
"@missing-elements/h5p-offline-player": "1.7.0",
3434
"@missing-elements/h5p-runtime": "1.0.2",

‎pnpm-lock.yaml‎

Lines changed: 11 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎vite.config.ts‎

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { fileURLToPath } from 'node:url'
66
import { gzipSync } from 'node:zlib'
77
import { buildPackage, writeBundles } from '@missing-elements/h5p-author'
88
import { Uint8ArrayReader, Uint8ArrayWriter, ZipWriter } from '@zip.js/zip.js'
9-
import { build, defineConfig, type Plugin } from 'vite'
9+
import { defineConfig, type Plugin } from 'vite'
1010

1111
/*
1212
* The site's H5P part, `/h5p/`, which Vite builds into `_site/` once Eleventy has written the pages
@@ -154,21 +154,22 @@ function sample(): Plugin {
154154
* 2026-11-13, its `npx` having timed out.
155155
* - `parts/`: every part of the pack under its own name, and its index. A bundle holds no addon,
156156
* so a build whose text calls for one stops and names its part, which the chat fetches from here.
157-
* - `h5p-author.mjs`: the command line as one file, everything it imports bundled in by Vite, so it
158-
* runs with nothing installed. It takes `--libraries`: the npm package's pinned pack is not with
159-
* it. Since 0.9.8 its `--version` prints the versions from copies of the two package.json files
160-
* Vite writes in (h5p-toolkit#198); before, it crashed, finding neither beside it. The
157+
* - `h5p-author.mjs`: the command line as one file, everything it imports bundled in, so it runs
158+
* with nothing installed. Copied as the author package ships it (`dist/`, built by its
159+
* `prepack` since 0.14.0, h5p-toolkit#247), so the bytes a chat runs are the npm package's,
160+
* which its provenance covers, and this site's build tools never touch them. It takes
161+
* `--libraries`: the npm package's pinned pack is not with it. Its `--version` prints the
162+
* versions from copies of the two package.json files bundled into it (h5p-toolkit#198). The
161163
* build runs it and stops where it does not print the versions `index.json` says.
162-
* - `h5p-author-LICENSES.txt`: every package bundled into `h5p-author.mjs` with its licence, as
163-
* Vite lists them, since MIT and BSD-3-Clause ask their notices to travel with copies (zod came
164-
* in with h5p-author 0.12.0; zip.js was in already). It goes into the archive with the tool.
164+
* - `h5p-author-LICENSES.txt`: every package bundled into `h5p-author.mjs` with its licence,
165+
* shipped beside it, since MIT and BSD-3-Clause ask their notices to travel with copies. It goes
166+
* into the archive with the tool.
165167
* - `index.json`: the author's and the pack's versions, and each bundle's file, size and parts.
166168
* - `libraries.txt`: the pack's licence list, which asks to travel with its libraries.
167169
*
168170
* Written after the page, from the packages the lockfile pins: `_site/` holds them, git does not.
169171
*/
170172
function bundles(): Plugin {
171-
const root = fileURLToPath(new URL('.', import.meta.url))
172173
const author = new URL('./node_modules/@missing-elements/h5p-author/', import.meta.url)
173174
const libraries = new URL('./node_modules/@missing-elements/h5p-libraries/', import.meta.url)
174175
const version = async (from: URL) => (JSON.parse(await readFile(new URL('package.json', from), 'utf8')) as { version: string }).version
@@ -188,23 +189,8 @@ function bundles(): Plugin {
188189
for (const { folder: part } of index.libraries) await copyFile(new URL(`parts/${part}.h5p`, libraries), join(parts, `${part}.h5p`))
189190
await copyFile(new URL('parts/index.json', libraries), join(parts, 'index.json'))
190191
await copyFile(new URL('libraries.txt', libraries), join(folder, 'libraries.txt'))
191-
await build({
192-
configFile: false,
193-
root,
194-
logLevel: 'warn',
195-
publicDir: false,
196-
build: {
197-
ssr: fileURLToPath(new URL('bin/h5p-author.mjs', author)),
198-
outDir: folder,
199-
emptyOutDir: false,
200-
copyPublicDir: false,
201-
minify: false,
202-
license: { fileName: 'h5p-author-LICENSES.txt' },
203-
reportCompressedSize: false,
204-
rolldownOptions: { output: { entryFileNames: 'h5p-author.mjs', format: 'es', codeSplitting: false } }
205-
},
206-
ssr: { noExternal: true, target: 'node' }
207-
})
192+
// The command line as one file and its licence list, as the author package ships them.
193+
for (const file of ['h5p-author.mjs', 'h5p-author-LICENSES.txt']) await copyFile(new URL(`dist/${file}`, author), join(folder, file))
208194
// The tool says its own versions, as a model checking it first asks: those this site pins.
209195
const expected = `@missing-elements/h5p-author ${await version(author)}, library pack ${await version(libraries)}`
210196
const printed = execFileSync(process.execPath, [join(folder, 'h5p-author.mjs'), '--version'], { encoding: 'utf8' }).trim()

0 commit comments

Comments
 (0)