UI: Fixed error JIT Compilation and correct process
This commit is contained in:
parent
77567b8863
commit
843151ba44
@ -17,7 +17,6 @@
|
||||
import {
|
||||
Compiler,
|
||||
Component,
|
||||
ComponentFactory,
|
||||
Injectable,
|
||||
Injector,
|
||||
NgModule,
|
||||
@ -26,9 +25,9 @@ import {
|
||||
Type,
|
||||
ɵresetCompiledComponents
|
||||
} from '@angular/core';
|
||||
import { from, Observable } from 'rxjs';
|
||||
import { from, Observable, of } from 'rxjs';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { catchError, map, mergeMap } from 'rxjs/operators';
|
||||
import { mergeMap } from 'rxjs/operators';
|
||||
|
||||
@NgModule()
|
||||
export abstract class DynamicComponentModule implements OnDestroy {
|
||||
@ -79,8 +78,8 @@ export class DynamicComponentFactoryService {
|
||||
declarations: [comp],
|
||||
imports: moduleImports
|
||||
})(class DynamicComponentInstanceModule extends DynamicComponentModule {});
|
||||
return from(this.compiler.compileModuleAsync(dynamicComponentInstanceModule)).pipe(
|
||||
map((module) => {
|
||||
try {
|
||||
const module = this.compiler.compileModuleSync(dynamicComponentInstanceModule);
|
||||
let moduleRef: NgModuleRef<any>;
|
||||
try {
|
||||
moduleRef = module.create(this.injector);
|
||||
@ -92,20 +91,19 @@ export class DynamicComponentFactoryService {
|
||||
moduleRef,
|
||||
moduleType: module.moduleType
|
||||
});
|
||||
return {
|
||||
return of( {
|
||||
componentType: comp,
|
||||
componentModuleRef: moduleRef
|
||||
};
|
||||
}),
|
||||
catchError((error) => {
|
||||
});
|
||||
} catch (error) {
|
||||
if (compileAttempt === 1) {
|
||||
ɵresetCompiledComponents();
|
||||
return this.createDynamicComponent(componentType, template, modules, preserveWhitespaces, ++compileAttempt, styles);
|
||||
} else {
|
||||
console.error(error);
|
||||
throw error;
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user