Skip to content

Commit b203591

Browse files
authored
fix(install) - reload non loaded envs during install before compile (#9130)
1 parent 197b440 commit b203591

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

scopes/harmony/aspect-loader/aspect-loader.main.runtime.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -766,13 +766,6 @@ export class AspectLoaderMain {
766766
await this.harmony.load(relevantManifests);
767767
} catch (e: any) {
768768
const ids = extensionsManifests.map((manifest) => manifest.id || 'unknown');
769-
// TODO: improve texts
770-
const errorMsg = e.message.split('\n')[0];
771-
const warning = UNABLE_TO_LOAD_EXTENSION_FROM_LIST(ids, errorMsg, neededFor);
772-
if (mergedOptions.ignoreErrors) return;
773-
if ((e.code === 'MODULE_NOT_FOUND' || e.code === 'ERR_MODULE_NOT_FOUND') && mergedOptions.hideMissingModuleError)
774-
return;
775-
this.logger.error(warning, e);
776769
if (mergedOptions.unifyErrorsByExtId) {
777770
const needToPrint = some(ids, (id) => !this.failedToLoadExt.has(id));
778771
if (!needToPrint) return;
@@ -786,6 +779,13 @@ export class AspectLoaderMain {
786779
}
787780
});
788781
}
782+
if (mergedOptions.ignoreErrors) return;
783+
if ((e.code === 'MODULE_NOT_FOUND' || e.code === 'ERR_MODULE_NOT_FOUND') && mergedOptions.hideMissingModuleError)
784+
return;
785+
// TODO: improve texts
786+
const errorMsg = e.message.split('\n')[0];
787+
const warning = UNABLE_TO_LOAD_EXTENSION_FROM_LIST(ids, errorMsg, neededFor);
788+
this.logger.error(warning, e);
789789
if (this.logger.isLoaderStarted) {
790790
if (mergedOptions.throwOnError) throw new BitError(warning);
791791
this.logger.consoleFailure(warning);

scopes/workspace/install/install.main.runtime.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,7 @@ export class InstallMain {
365365
let cacheCleared = false;
366366
await this.linkCodemods(compDirMap);
367367
await this.reloadMovedEnvs();
368+
await this.reloadNonLoadedEnvs();
368369
const shouldClearCacheOnInstall = this.shouldClearCacheOnInstall();
369370
if (options?.compile ?? true) {
370371
const compileStartTime = process.hrtime();
@@ -460,10 +461,18 @@ export class InstallMain {
460461
return !regularPathExists || !resolvedPathExists;
461462
});
462463
const idsToLoad = movedEnvs.map((env) => env.id);
463-
// const envPlugin = this.envs.getEnvPlugin();
464+
const componentIdsToLoad = idsToLoad.map((id) => ComponentID.fromString(id));
465+
await this.reloadEnvs(componentIdsToLoad);
466+
}
467+
468+
private async reloadNonLoadedEnvs() {
469+
const nonLoadedEnvs = this.envs.getFailedToLoadEnvs();
470+
const componentIdsToLoad = nonLoadedEnvs.map((id) => ComponentID.fromString(id));
471+
await this.reloadEnvs(componentIdsToLoad);
472+
}
464473

465-
if (idsToLoad.length && this.workspace) {
466-
const componentIdsToLoad = idsToLoad.map((id) => ComponentID.fromString(id));
474+
private async reloadEnvs(componentIdsToLoad: ComponentID[]) {
475+
if (componentIdsToLoad.length && this.workspace) {
467476
const aspects = await this.workspace.resolveAspects(undefined, componentIdsToLoad, {
468477
requestedOnly: true,
469478
excludeCore: true,
@@ -493,7 +502,6 @@ export class InstallMain {
493502
})
494503
);
495504
}
496-
return movedEnvs;
497505
}
498506

499507
private async _getComponentsManifestsAndRootPolicy(

0 commit comments

Comments
 (0)