| 1234 | } |
| 1235 | |
| 1236 | add(id: string, source: string, mappings?: string): SourceModule { |
| 1237 | const existing = this.modulesById[id] |
| 1238 | // a program evaluates a module once, so it stays as the graph holds it |
| 1239 | if (existing instanceof SourceModule && existing.source === source) |
| 1240 | return existing |
| 1241 | if (existing) this.forget([id]) |
| 1242 | const module = new SourceModule(id, source, this.pathOf(id), mappings) |
| 1243 | this.modulesById[id] = module |
| 1244 | return module |
| 1245 | } |
| 1246 | |
| 1247 | // modules read again, as each importer read the previous version, so it's |
| 1248 | // evaluated again: the modules it held of them and their importers |