| 192 | // the sources a precompiled program loads, through any package's runtime |
| 193 | // entries, which keep their bytes as they're written |
| 194 | const precompiledSources = (): Set<string> => { |
| 195 | const entries = Object.values(packagesByScope).flatMap(({ path, json }) => |
| 196 | Object.entries( |
| 197 | json.exports as Record<string, { "ark-ts"?: unknown }> |
| 198 | ).flatMap(([subpath, target]) => { |
| 199 | const source = target["ark-ts"] as string | { default: string } |
| 200 | return ( |
| 201 | subpath.startsWith("./runtime") || |
| 202 | subpath.startsWith("./schema/runtime") |
| 203 | ) ? |
| 204 | [join(path, typeof source === "string" ? source : source.default)] |
| 205 | : [] |
| 206 | }) |
| 207 | ) |
| 208 | const { metafile } = buildSync({ |
| 209 | entryPoints: entries, |
| 210 | bundle: true, |
| 211 | format: "esm", |
| 212 | platform: "neutral", |
| 213 | conditions: ["ark-ts"], |
| 214 | absWorkingDir: repoDirs.root, |
| 215 | outdir: "out", |
| 216 | write: false, |
| 217 | metafile: true, |
| 218 | logLevel: "error" |
| 219 | }) |
| 220 | return new Set( |
| 221 | Object.keys(metafile.inputs).map(input => join(repoDirs.root, input)) |
| 222 | ) |
| 223 | } |
| 224 | |
| 225 | // the source tsc wrote an input of the bundle from |
| 226 | const sourceOf = (input: string) => |