@@ -6,7 +6,7 @@ import { fileURLToPath } from 'node:url'
66import { gzipSync } from 'node:zlib'
77import { buildPackage , writeBundles } from '@missing-elements/h5p-author'
88import { 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 */
170172function 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