(name: string, ...args: any[])
| 48 | |
| 49 | export const loaded = []; |
| 50 | export async function loadFeatures(name: string, ...args: any[]) { |
| 51 | if (loaded.includes(name)) return; |
| 52 | loaded.push(name); |
| 53 | for (const item of await getFeatures(name)) { |
| 54 | let apply = typeof item === 'function' |
| 55 | ? item |
| 56 | : (item.startsWith('http') || item.startsWith('/')) |
| 57 | ? await legacyLoadExternalModule(item) |
| 58 | : (await load(item)).apply; |
| 59 | if (typeof apply !== 'function') apply = apply.default || apply.apply; |
| 60 | if (typeof apply === 'function') await apply(...args); |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | export function provideFeature(name: string, content: string | (() => Promise<any>)) { |
| 65 | console.debug('Providing feature', name); |
nothing calls this directly
no test coverage detected