Download this file
| 1 | // fixtures/colophon-inputs.mjs — prints, as JSON, every input file |
| 2 | // esbuild reads to build the shipped bundles (bundles.mjs), relative to |
| 3 | // this directory. internal/shipped runs it and names the npm packages |
| 4 | // those files are in; that list is the Colophon's JavaScript section. |
| 5 | // Nothing is written: the build is in memory. |
| 6 | import { build } from 'esbuild' |
| 7 | import { join, dirname } from 'node:path' |
| 8 | import { fileURLToPath } from 'node:url' |
| 9 | import { bundles, options } from './bundles.mjs' |
| 10 | |
| 11 | const here = dirname(fileURLToPath(import.meta.url)) |
| 12 | const inputs = new Set() |
| 13 | for (const { name, entry, format = 'esm' } of bundles) { |
| 14 | const result = await build({ ...options, entryPoints: [join(here, entry)], format, outfile: join(here, `${name}.js`), write: false, metafile: true, absWorkingDir: here }) |
| 15 | for (const path of Object.keys(result.metafile.inputs)) inputs.add(path) |
| 16 | } |
| 17 | console.log(JSON.stringify([...inputs].sort())) |
| 18 | |