| 129 | } |
| 130 | |
| 131 | function getTransitiveDeps(symbol) { |
| 132 | // TODO(sbc): Use some kind of cache to avoid quadratic behaviour here. |
| 133 | const transitiveDeps = new Set(); |
| 134 | const seen = new Set(); |
| 135 | const toVisit = [symbol]; |
| 136 | while (toVisit.length) { |
| 137 | const sym = toVisit.pop(); |
| 138 | if (!seen.has(sym)) { |
| 139 | let directDeps = LibraryManager.library[sym + '__deps'] ?? []; |
| 140 | directDeps = directDeps.filter((d) => typeof d === 'string'); |
| 141 | for (const dep of directDeps) { |
| 142 | if (!transitiveDeps.has(dep)) { |
| 143 | debugLog(`adding dependency ${symbol} -> ${dep}`); |
| 144 | } |
| 145 | transitiveDeps.add(dep); |
| 146 | toVisit.push(dep); |
| 147 | } |
| 148 | seen.add(sym); |
| 149 | } |
| 150 | } |
| 151 | return Array.from(transitiveDeps); |
| 152 | } |
| 153 | |
| 154 | function shouldPreprocess(fileName) { |
| 155 | var content = readFile(fileName).trim(); |