Skip to content

Commit

Permalink
supporting multiple eps (#242)
Browse files Browse the repository at this point in the history
  • Loading branch information
amiryonatan authored Oct 30, 2023
1 parent d35d3f9 commit c0bf3af
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/repluggableAppDebug/repluggableAppDebug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ interface SetupDebugInfoParams {
getAPI: AppHost['getAPI']
}

async function resolveEntryPoints(repluggableArtifacts: Record<string, EntryPointOrPackage | Function>) {
async function resolveEntryPoints(repluggableArtifacts: Record<string, EntryPointOrPackage | Function>): Promise<EntryPoint[]> {
const allPackages = await Promise.all(_.values(repluggableArtifacts).map(x => (typeof x === 'function' ? x() : x))).then(x =>
_.flattenDeep(x.map(y => _.values(y)))
)
Expand All @@ -56,17 +56,21 @@ function mapApiToEntryPoint(allPackages: EntryPoint[]) {

const getAPIOrEntryPointsDependencies = async (
repluggableArtifacts: Record<string, EntryPointOrPackage | Function>,
apiOrPackageName: string
apisOrEntryPoints: string[]
): Promise<{ entryPoints: EntryPoint[]; apis: AnySlotKey[] }> => {
const allPackages = await resolveEntryPoints(repluggableArtifacts)
const apiToEntryPoint = mapApiToEntryPoint(allPackages)

const loadedEntryPoints = new Set<string>()
const packagesList: EntryPoint[] = []
const allDependencies = new Set<AnySlotKey>()
const entryPointsQueue: EntryPoint[] = allPackages.filter(
x => x.name === apiOrPackageName || x.name === apiToEntryPoint.get(apiOrPackageName)?.name
)
const apisOrEntryPointsSet = new Set(apisOrEntryPoints)
const entryPointsQueue: EntryPoint[] = allPackages.filter(x => apisOrEntryPointsSet.has(x.name))

apisOrEntryPoints.forEach(x => {
const ep = apiToEntryPoint.get(x)
ep && entryPointsQueue.push(ep)
})

while (entryPointsQueue.length) {
const currEntryPoint = entryPointsQueue.shift()
Expand Down

0 comments on commit c0bf3af

Please sign in to comment.