@@ -49,6 +49,7 @@ import {
4949 MergeOptions ,
5050} from './merge-version' ;
5151import { ConfigStoreAspect , ConfigStoreMain } from '@teambit/config-store' ;
52+ import { ApplicationAspect , ApplicationMain } from '@teambit/application' ;
5253
5354type ResolveUnrelatedData = {
5455 strategy : MergeStrategy ;
@@ -124,7 +125,8 @@ export class MergingMain {
124125 private config : ConfigMain ,
125126 private remove : RemoveMain ,
126127 private configMerger : ConfigMergerMain ,
127- private depResolver : DependencyResolverMain
128+ private depResolver : DependencyResolverMain ,
129+ private application : ApplicationMain
128130 ) { }
129131
130132 async merge (
@@ -297,7 +299,14 @@ export class MergingMain {
297299
298300 const componentsHasConfigMergeConflicts = allComponentsStatus . some ( ( c ) => c . configMergeResult ?. hasConflicts ( ) ) ;
299301 const leftUnresolvedConflicts = componentWithConflict && mergeStrategy === 'manual' ;
302+
300303 if ( ! skipDependencyInstallation && ! leftUnresolvedConflicts && ! componentsHasConfigMergeConflicts ) {
304+ // this is a workaround.
305+ // keep this here. although it gets called before snapping.
306+ // the reason is that when the installation is running, for some reason, some apps are unable to load in the same process.
307+ // they throw an error "Cannot find module" during the aspect loading.
308+ await this . application . loadAllAppsAsAspects ( ) ;
309+
301310 try {
302311 await this . install . install ( undefined , {
303312 dedupe : true ,
@@ -327,8 +336,13 @@ export class MergingMain {
327336 const { taggedComponents, autoTaggedResults, removedComponents } = results ;
328337 return { snappedComponents : taggedComponents , autoSnappedResults : autoTaggedResults , removedComponents } ;
329338 }
330- return this . snapResolvedComponents ( allComponentsStatus , snapMessage , build , currentLane ?. toLaneId ( ) ,
331- updatedComponents ) ;
339+ return this . snapResolvedComponents (
340+ allComponentsStatus ,
341+ snapMessage ,
342+ build ,
343+ currentLane ?. toLaneId ( ) ,
344+ updatedComponents
345+ ) ;
332346 } ;
333347 let mergeSnapResults : MergeSnapResults = null ;
334348 let mergeSnapError : Error | undefined ;
@@ -637,7 +651,11 @@ export class MergingMain {
637651 . filter ( ( c ) => {
638652 const conflictedAspects = c . dataMergeResult ?. conflictedAspects || { } ;
639653 const aspectIds = Object . keys ( conflictedAspects ) ;
640- aspectIds . forEach ( aspectId => this . logger . debug ( `conflicted-data for "${ c . id . toString ( ) } ". aspectId: ${ aspectId } . reason: ${ conflictedAspects [ aspectId ] } ` ) ) ;
654+ aspectIds . forEach ( ( aspectId ) =>
655+ this . logger . debug (
656+ `conflicted-data for "${ c . id . toString ( ) } ". aspectId: ${ aspectId } . reason: ${ conflictedAspects [ aspectId ] } `
657+ )
658+ ) ;
641659 return aspectIds . length ;
642660 } )
643661 . map ( ( c ) => c . id ) ;
@@ -740,6 +758,7 @@ export class MergingMain {
740758 ConfigStoreAspect ,
741759 ConfigMergerAspect ,
742760 DependencyResolverAspect ,
761+ ApplicationAspect ,
743762 ] ;
744763 static runtime = MainRuntime ;
745764 static async provider ( [
@@ -757,6 +776,7 @@ export class MergingMain {
757776 configStore ,
758777 configMerger ,
759778 depResolver ,
779+ application ,
760780 ] : [
761781 CLIMain ,
762782 Workspace ,
@@ -772,6 +792,7 @@ export class MergingMain {
772792 ConfigStoreMain ,
773793 ConfigMergerMain ,
774794 DependencyResolverMain ,
795+ ApplicationMain ,
775796 ] ) {
776797 const logger = loggerMain . createLogger ( MergingAspect . id ) ;
777798 const merging = new MergingMain (
@@ -786,7 +807,8 @@ export class MergingMain {
786807 config ,
787808 remove ,
788809 configMerger ,
789- depResolver
810+ depResolver ,
811+ application
790812 ) ;
791813 cli . register ( new MergeCmd ( merging , configStore ) ) ;
792814 return merging ;
0 commit comments