refactor(compiler): split compiler and core (#18683)
After this, neither @angular/compiler nor @angular/comnpiler-cli depend on @angular/core. This add a duplication of some interfaces and enums which is stored in @angular/compiler/src/core.ts BREAKING CHANGE: - `@angular/platform-server` now additionally depends on `@angular/platform-browser-dynamic` as a peer dependency. PR Close #18683
This commit is contained in:

committed by
Miško Hevery

parent
a0ca01d580
commit
0cc77b4a69
@ -6,7 +6,7 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {ApplicationInitStatus, CompilerOptions, Component, Directive, InjectionToken, Injector, ModuleWithComponentFactories, NgModule, NgModuleFactory, NgModuleRef, NgZone, Optional, Pipe, PlatformRef, Provider, SchemaMetadata, SkipSelf, Type, ɵDepFlags as DepFlags, ɵERROR_COMPONENT_TYPE, ɵNodeFlags as NodeFlags, ɵclearProviderOverrides as clearProviderOverrides, ɵoverrideProvider as overrideProvider, ɵstringify as stringify} from '@angular/core';
|
||||
import {ApplicationInitStatus, CompilerOptions, Component, Directive, InjectionToken, Injector, ModuleWithComponentFactories, NgModule, NgModuleFactory, NgModuleRef, NgZone, Optional, Pipe, PlatformRef, Provider, SchemaMetadata, SkipSelf, Type, ɵDepFlags as DepFlags, ɵNodeFlags as NodeFlags, ɵclearProviderOverrides as clearProviderOverrides, ɵoverrideProvider as overrideProvider, ɵstringify as stringify} from '@angular/core';
|
||||
|
||||
import {AsyncTestCompleter} from './async_test_completer';
|
||||
import {ComponentFixture} from './component_fixture';
|
||||
@ -298,9 +298,10 @@ export class TestBed implements Injector {
|
||||
this._moduleFactory =
|
||||
this._compiler.compileModuleAndAllComponentsSync(moduleType).ngModuleFactory;
|
||||
} catch (e) {
|
||||
if (getComponentType(e)) {
|
||||
const errorCompType = this._compiler.getComponentFromError(e);
|
||||
if (errorCompType) {
|
||||
throw new Error(
|
||||
`This test module uses the component ${stringify(getComponentType(e))} which is using a "templateUrl" or "styleUrls", but they were never compiled. ` +
|
||||
`This test module uses the component ${stringify(errorCompType)} which is using a "templateUrl" or "styleUrls", but they were never compiled. ` +
|
||||
`Please call "TestBed.compileComponents" before your test.`);
|
||||
} else {
|
||||
throw e;
|
||||
@ -551,7 +552,3 @@ export function withModule(moduleDef: TestModuleMetadata, fn?: Function | null):
|
||||
}
|
||||
return new InjectSetupWrapper(() => moduleDef);
|
||||
}
|
||||
|
||||
function getComponentType(error: Error): Function {
|
||||
return (error as any)[ɵERROR_COMPONENT_TYPE];
|
||||
}
|
||||
|
@ -45,6 +45,12 @@ export class TestingCompiler extends Compiler {
|
||||
* `compileModuleAndAllComponents*`.
|
||||
*/
|
||||
getComponentFactory<T>(component: Type<T>): ComponentFactory<T> { throw unimplemented(); }
|
||||
|
||||
/**
|
||||
* Returns the component type that is stored in the given error.
|
||||
* This can be used for errors created by compileModule...
|
||||
*/
|
||||
getComponentFromError(error: Error): Type<any>|null { throw unimplemented(); }
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user