( compartmentPrivateFields, moduleAliases, compartment, moduleSpecifier)
| 8078 | * This graph is then ready to be synchronously linked and executed. |
| 8079 | */ |
| 8080 | const load= async( |
| 8081 | compartmentPrivateFields, |
| 8082 | moduleAliases, |
| 8083 | compartment, |
| 8084 | moduleSpecifier)=> |
| 8085 | { |
| 8086 | const { name: compartmentName}= weakmapGet( |
| 8087 | compartmentPrivateFields, |
| 8088 | compartment); |
| 8089 | |
| 8090 | |
| 8091 | /** @type {Set<Promise<undefined>>} */ |
| 8092 | const pendingJobs= new Set(); |
| 8093 | /** @type {Map<object, Map<string, Promise<Record<any, any>>>>} */ |
| 8094 | const moduleLoads= new Map(); |
| 8095 | /** @type {Array<Error>} */ |
| 8096 | const errors= []; |
| 8097 | |
| 8098 | const dependencyLoaded= memoizedLoadWithErrorAnnotation( |
| 8099 | compartmentPrivateFields, |
| 8100 | moduleAliases, |
| 8101 | compartment, |
| 8102 | moduleSpecifier, |
| 8103 | pendingJobs, |
| 8104 | moduleLoads, |
| 8105 | errors); |
| 8106 | |
| 8107 | setAdd( |
| 8108 | pendingJobs, |
| 8109 | promiseThen(dependencyLoaded, noop, (error)=>{ |
| 8110 | arrayPush(errors, error); |
| 8111 | })); |
| 8112 | |
| 8113 | |
| 8114 | // Drain pending jobs queue. |
| 8115 | // Each job is a promise for undefined, regardless of success or failure. |
| 8116 | // Before we add a job to the queue, we catch any error and push it into the |
| 8117 | // `errors` accumulator. |
| 8118 | for( const job of pendingJobs) { |
| 8119 | // eslint-disable-next-line no-await-in-loop |
| 8120 | await job; |
| 8121 | } |
| 8122 | |
| 8123 | // Throw an aggregate error if there were any errors. |
| 8124 | if( errors.length> 0) { |
| 8125 | throw TypeError( |
| 8126 | `Failed to load module ${q(moduleSpecifier)} in package ${q( |
| 8127 | compartmentName) |
| 8128 | } (${errors.length} underlying failures: ${arrayJoin( |
| 8129 | arrayMap(errors, (error)=>error.message), |
| 8130 | ', ') |
| 8131 | }`); |
| 8132 | |
| 8133 | } |
| 8134 | };$h_once.load(load); |
| 8135 | })() |
| 8136 | , |
| 8137 | // === functors[39] === |
no test coverage detected