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:
Tobias Bosch
2017-08-16 09:00:03 -07:00
committed by Miško Hevery
parent a0ca01d580
commit 0cc77b4a69
107 changed files with 1504 additions and 1564 deletions

View File

@ -6,27 +6,23 @@
* found in the LICENSE file at https://angular.io/license
*/
import {NgModule, Type, ɵstringify as stringify} from '@angular/core';
import {CompileReflector} from './compile_reflector';
import {NgModule, Type, createNgModule} from './core';
import {findLast} from './directive_resolver';
import {CompilerInjectable} from './injectable';
import {stringify} from './util';
function _isNgModuleMetadata(obj: any): obj is NgModule {
return obj instanceof NgModule;
}
/**
* Resolves types to {@link NgModule}.
*/
@CompilerInjectable()
export class NgModuleResolver {
constructor(private _reflector: CompileReflector) {}
isNgModule(type: any) { return this._reflector.annotations(type).some(_isNgModuleMetadata); }
isNgModule(type: any) { return this._reflector.annotations(type).some(createNgModule.isTypeOf); }
resolve(type: Type<any>, throwIfNotFound = true): NgModule|null {
const ngModuleMeta: NgModule = findLast(this._reflector.annotations(type), _isNgModuleMetadata);
resolve(type: Type, throwIfNotFound = true): NgModule|null {
const ngModuleMeta: NgModule =
findLast(this._reflector.annotations(type), createNgModule.isTypeOf);
if (ngModuleMeta) {
return ngModuleMeta;