| 3197 | |
| 3198 | // Rolldown's module info has no isExternal, but no code for an external |
| 3199 | const rollupBundleOf = (context: RollupContext): BundleModules => { |
| 3200 | const bundle: BundleModules = { externals: [], files: [], importerOf: {} } |
| 3201 | const seen = new Set<string>() |
| 3202 | const add = (id: string) => { |
| 3203 | if (seen.has(id)) return |
| 3204 | seen.add(id) |
| 3205 | const info = context.getModuleInfo(id) |
| 3206 | if (!info || (info.isExternal ?? info.code === null)) |
| 3207 | bundle.externals.push(id) |
| 3208 | else bundle.files.push(id) |
| 3209 | } |
| 3210 | for (const id of context.getModuleIds()) { |
| 3211 | add(id) |
| 3212 | const info = context.getModuleInfo(id) |
| 3213 | for (const target of [ |
| 3214 | ...(info?.importedIds ?? []), |
| 3215 | ...(info?.dynamicallyImportedIds ?? []) |
| 3216 | ]) { |
| 3217 | add(target) |
| 3218 | bundle.importerOf[target] ??= id |
| 3219 | } |
| 3220 | } |
| 3221 | return bundle |
| 3222 | } |
| 3223 | |
| 3224 | const esbuildBundleOf = (metafile: Metafile, cwd: string): BundleModules => ({ |
| 3225 | externals: Object.values(metafile.outputs).flatMap( |