revert: fix(ivy): Only restore registered modules if user compiles modules with TestBed (#32944) (#33663)
This commit reverts 63256b5
.
PR Close #33663
This commit is contained in:

committed by
Kara Erickson

parent
4988094e7d
commit
f8e9c1e6f1
@ -35,7 +35,7 @@ import {MetadataOverride} from './metadata_override';
|
||||
import {TestBed} from './test_bed';
|
||||
import {ComponentFixtureAutoDetect, ComponentFixtureNoNgZone, TestBedStatic, TestComponentRenderer, TestModuleMetadata} from './test_bed_common';
|
||||
import {R3TestBedCompiler} from './r3_test_bed_compiler';
|
||||
import {clearRegisteredModuleState} from '../../src/linker/ng_module_factory_registration';
|
||||
import {clearModuleRegistry} from '../../src/linker/ng_module_factory_registration';
|
||||
|
||||
let _nextRootElementId = 0;
|
||||
|
||||
@ -229,6 +229,7 @@ export class TestBedRender3 implements TestBed {
|
||||
}
|
||||
|
||||
resetTestingModule(): void {
|
||||
clearModuleRegistry();
|
||||
this.checkGlobalCompilationFinished();
|
||||
resetCompiledComponents();
|
||||
if (this._compiler !== null) {
|
||||
|
@ -9,7 +9,6 @@
|
||||
import {ResourceLoader} from '@angular/compiler';
|
||||
import {ApplicationInitStatus, COMPILER_OPTIONS, Compiler, Component, Directive, Injector, InjectorType, LOCALE_ID, ModuleWithComponentFactories, ModuleWithProviders, NgModule, NgModuleFactory, NgZone, Pipe, PlatformRef, Provider, Type, ɵDEFAULT_LOCALE_ID as DEFAULT_LOCALE_ID, ɵDirectiveDef as DirectiveDef, ɵNG_COMP_DEF as NG_COMP_DEF, ɵNG_DIR_DEF as NG_DIR_DEF, ɵNG_INJ_DEF as NG_INJ_DEF, ɵNG_MOD_DEF as NG_MOD_DEF, ɵNG_PIPE_DEF as NG_PIPE_DEF, ɵNgModuleFactory as R3NgModuleFactory, ɵNgModuleTransitiveScopes as NgModuleTransitiveScopes, ɵNgModuleType as NgModuleType, ɵRender3ComponentFactory as ComponentFactory, ɵRender3NgModuleRef as NgModuleRef, ɵcompileComponent as compileComponent, ɵcompileDirective as compileDirective, ɵcompileNgModuleDefs as compileNgModuleDefs, ɵcompilePipe as compilePipe, ɵgetInjectableDef as getInjectableDef, ɵpatchComponentDefWithScope as patchComponentDefWithScope, ɵsetLocaleId as setLocaleId, ɵtransitiveScopesFor as transitiveScopesFor, ɵɵInjectableDef as InjectableDef} from '@angular/core';
|
||||
|
||||
import {ModuleRegistrationMap, getRegisteredModulesState, restoreRegisteredModulesState} from '../../src/linker/ng_module_factory_registration';
|
||||
import {clearResolutionOfComponentResourcesQueue, isComponentDefPendingResolution, resolveComponentResources, restoreComponentResolutionQueue} from '../../src/metadata/resource_loading';
|
||||
|
||||
import {MetadataOverride} from './metadata_override';
|
||||
@ -42,7 +41,6 @@ interface CleanupOperation {
|
||||
|
||||
export class R3TestBedCompiler {
|
||||
private originalComponentResolutionQueue: Map<Type<any>, Component>|null = null;
|
||||
private originalRegisteredModules: null|ModuleRegistrationMap = null;
|
||||
|
||||
// Testing module configuration
|
||||
private declarations: Type<any>[] = [];
|
||||
@ -277,9 +275,6 @@ export class R3TestBedCompiler {
|
||||
* @internal
|
||||
*/
|
||||
async _compileNgModuleAsync(moduleType: Type<any>): Promise<void> {
|
||||
if (this.originalRegisteredModules === null) {
|
||||
this.originalRegisteredModules = getRegisteredModulesState();
|
||||
}
|
||||
this.queueTypesFromModulesArray([moduleType]);
|
||||
await this.compileComponents();
|
||||
this.applyProviderOverrides();
|
||||
@ -567,10 +562,6 @@ export class R3TestBedCompiler {
|
||||
this.initialNgDefs.clear();
|
||||
this.moduleProvidersOverridden.clear();
|
||||
this.restoreComponentResolutionQueue();
|
||||
if (this.originalRegisteredModules) {
|
||||
restoreRegisteredModulesState(this.originalRegisteredModules);
|
||||
this.originalRegisteredModules = null;
|
||||
}
|
||||
// Restore the locale ID to the default value, this shouldn't be necessary but we never know
|
||||
setLocaleId(DEFAULT_LOCALE_ID);
|
||||
}
|
||||
|
Reference in New Issue
Block a user