| 1238 | } |
| 1239 | |
| 1240 | export const writePrecompiledUnits = ( |
| 1241 | roots: readonly BaseRoot[] |
| 1242 | ): Record<string, string> => { |
| 1243 | const unitsByKey: Record<string, string | undefined> = {} |
| 1244 | const keysById: Record<NodeId, string> = {} |
| 1245 | const keyOf = (root: BaseRoot) => |
| 1246 | (keysById[root.id] ??= precompiledKeyOf(root)) |
| 1247 | for (const root of roots) { |
| 1248 | if (root.hasAlias || keyOf(root) in unitsByKey) continue |
| 1249 | for (const unit of precompileRootUnits(root)) { |
| 1250 | const key = keyOf(unit.roots[0]) |
| 1251 | if (!(key in unitsByKey)) |
| 1252 | unitsByKey[key] = writePrecompiledUnit(unit, unitsByKey, keyOf) |
| 1253 | } |
| 1254 | } |
| 1255 | const written: Record<string, string> = {} |
| 1256 | for (const key of Object.keys(unitsByKey).sort()) |
| 1257 | if (unitsByKey[key]) written[key] = unitsByKey[key] |
| 1258 | return written |
| 1259 | } |
| 1260 | |
| 1261 | const writePrecompiledUnit = ( |
| 1262 | unit: RootUnit, |