fix(packages): use ES modules for primary build (#11120)
This commit is contained in:

committed by
Victor Berchet

parent
8cb1046ce9
commit
979657989b
@ -5,13 +5,12 @@
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {DirectiveResolver} from '@angular/compiler';
|
||||
import {AnimationEntryMetadata, Compiler, ComponentMetadata, DirectiveMetadata, Injectable, Injector, Provider, Type, resolveForwardRef} from '@angular/core';
|
||||
import {ViewMetadata} from '../core_private';
|
||||
|
||||
import {DirectiveResolver} from '../src/directive_resolver';
|
||||
import {Map} from '../src/facade/collection';
|
||||
import {isArray, isPresent} from '../src/facade/lang';
|
||||
import {Map} from './facade/collection';
|
||||
import {isArray, isPresent} from './facade/lang';
|
||||
import {ViewMetadata} from './private_import_core';
|
||||
|
||||
|
||||
|
||||
|
1
modules/@angular/compiler/testing/facade
Symbolic link
1
modules/@angular/compiler/testing/facade
Symbolic link
@ -0,0 +1 @@
|
||||
../../facade/src
|
116
modules/@angular/compiler/testing/index.ts
Normal file
116
modules/@angular/compiler/testing/index.ts
Normal file
@ -0,0 +1,116 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
/**
|
||||
* @module
|
||||
* @description
|
||||
* Entry point for all APIs of the compiler package.
|
||||
*
|
||||
* <div class="callout is-critical">
|
||||
* <header>Unstable APIs</header>
|
||||
* <p>
|
||||
* All compiler apis are currently considered experimental and private!
|
||||
* </p>
|
||||
* <p>
|
||||
* We expect the APIs in this package to keep on changing. Do not rely on them.
|
||||
* </p>
|
||||
* </div>
|
||||
*/
|
||||
export * from './schema_registry_mock';
|
||||
export * from './directive_resolver_mock';
|
||||
export * from './ng_module_resolver_mock';
|
||||
export * from './pipe_resolver_mock';
|
||||
|
||||
import {createPlatformFactory, ModuleWithComponentFactories, Injectable, CompilerOptions, COMPILER_OPTIONS, CompilerFactory, ComponentFactory, NgModuleFactory, Injector, NgModuleMetadata, NgModuleMetadataType, ComponentMetadata, ComponentMetadataType, DirectiveMetadata, DirectiveMetadataType, PipeMetadata, PipeMetadataType, Type, PlatformRef} from '@angular/core';
|
||||
import {MetadataOverride} from '@angular/core/testing';
|
||||
import {TestingCompilerFactory, TestingCompiler} from './private_import_core';
|
||||
import {platformCoreDynamic, RuntimeCompiler, DirectiveResolver, NgModuleResolver, PipeResolver} from '@angular/compiler';
|
||||
import {MockDirectiveResolver} from './directive_resolver_mock';
|
||||
import {MockNgModuleResolver} from './ng_module_resolver_mock';
|
||||
import {MockPipeResolver} from './pipe_resolver_mock';
|
||||
import {MetadataOverrider} from './metadata_overrider';
|
||||
|
||||
@Injectable()
|
||||
export class TestingCompilerFactoryImpl implements TestingCompilerFactory {
|
||||
constructor(private _compilerFactory: CompilerFactory) {}
|
||||
|
||||
createTestingCompiler(options: CompilerOptions[]): TestingCompiler {
|
||||
const compiler = <RuntimeCompiler>this._compilerFactory.createCompiler(options);
|
||||
return new TestingCompilerImpl(
|
||||
compiler, compiler.injector.get(MockDirectiveResolver),
|
||||
compiler.injector.get(MockPipeResolver), compiler.injector.get(MockNgModuleResolver));
|
||||
}
|
||||
}
|
||||
|
||||
export class TestingCompilerImpl implements TestingCompiler {
|
||||
private _overrider = new MetadataOverrider();
|
||||
constructor(
|
||||
private _compiler: RuntimeCompiler, private _directiveResolver: MockDirectiveResolver,
|
||||
private _pipeResolver: MockPipeResolver, private _moduleResolver: MockNgModuleResolver) {}
|
||||
get injector(): Injector { return this._compiler.injector; }
|
||||
|
||||
compileModuleSync<T>(moduleType: Type<T>): NgModuleFactory<T> {
|
||||
return this._compiler.compileModuleSync(moduleType);
|
||||
}
|
||||
|
||||
compileModuleAsync<T>(moduleType: Type<T>): Promise<NgModuleFactory<T>> {
|
||||
return this._compiler.compileModuleAsync(moduleType);
|
||||
}
|
||||
compileModuleAndAllComponentsSync<T>(moduleType: Type<T>): ModuleWithComponentFactories<T> {
|
||||
return this._compiler.compileModuleAndAllComponentsSync(moduleType);
|
||||
}
|
||||
|
||||
compileModuleAndAllComponentsAsync<T>(moduleType: Type<T>):
|
||||
Promise<ModuleWithComponentFactories<T>> {
|
||||
return this._compiler.compileModuleAndAllComponentsAsync(moduleType);
|
||||
}
|
||||
|
||||
overrideModule(ngModule: Type<any>, override: MetadataOverride<NgModuleMetadataType>): void {
|
||||
const oldMetadata = this._moduleResolver.resolve(ngModule, false);
|
||||
this._moduleResolver.setNgModule(
|
||||
ngModule, this._overrider.overrideMetadata(NgModuleMetadata, oldMetadata, override));
|
||||
}
|
||||
overrideDirective(directive: Type<any>, override: MetadataOverride<DirectiveMetadataType>): void {
|
||||
const oldMetadata = this._directiveResolver.resolve(directive, false);
|
||||
this._directiveResolver.setDirective(
|
||||
directive, this._overrider.overrideMetadata(DirectiveMetadata, oldMetadata, override));
|
||||
}
|
||||
overrideComponent(component: Type<any>, override: MetadataOverride<ComponentMetadataType>): void {
|
||||
const oldMetadata = this._directiveResolver.resolve(component, false);
|
||||
this._directiveResolver.setDirective(
|
||||
component, this._overrider.overrideMetadata(ComponentMetadata, oldMetadata, override));
|
||||
}
|
||||
overridePipe(pipe: Type<any>, override: MetadataOverride<PipeMetadataType>): void {
|
||||
const oldMetadata = this._pipeResolver.resolve(pipe, false);
|
||||
this._pipeResolver.setPipe(
|
||||
pipe, this._overrider.overrideMetadata(PipeMetadata, oldMetadata, override));
|
||||
}
|
||||
clearCache(): void { this._compiler.clearCache(); }
|
||||
clearCacheFor(type: Type<any>) { this._compiler.clearCacheFor(type); }
|
||||
}
|
||||
|
||||
/**
|
||||
* Platform for dynamic tests
|
||||
*
|
||||
* @experimental
|
||||
*/
|
||||
export const platformCoreDynamicTesting: (extraProviders?: any[]) => PlatformRef =
|
||||
createPlatformFactory(platformCoreDynamic, 'coreDynamicTesting', [
|
||||
{
|
||||
provide: COMPILER_OPTIONS,
|
||||
useValue: {
|
||||
providers: [
|
||||
MockPipeResolver, {provide: PipeResolver, useExisting: MockPipeResolver},
|
||||
MockDirectiveResolver, {provide: DirectiveResolver, useExisting: MockDirectiveResolver},
|
||||
MockNgModuleResolver, {provide: NgModuleResolver, useExisting: MockNgModuleResolver}
|
||||
]
|
||||
},
|
||||
multi: true
|
||||
},
|
||||
{provide: TestingCompilerFactory, useClass: TestingCompilerFactoryImpl}
|
||||
]);
|
@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
import {MetadataOverride} from '@angular/core/testing';
|
||||
import {stringify} from '../src/facade/lang';
|
||||
import {stringify} from './facade/lang';
|
||||
|
||||
type StringMap = {
|
||||
[key: string]: any
|
||||
|
@ -6,10 +6,10 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {NgModuleResolver} from '@angular/compiler';
|
||||
import {Compiler, Injectable, Injector, NgModuleMetadata, Type} from '@angular/core';
|
||||
|
||||
import {NgModuleResolver} from '../index';
|
||||
import {Map} from '../src/facade/collection';
|
||||
import {Map} from './facade/collection';
|
||||
|
||||
@Injectable()
|
||||
export class MockNgModuleResolver extends NgModuleResolver {
|
||||
|
@ -6,10 +6,10 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {PipeResolver} from '@angular/compiler';
|
||||
import {Compiler, Injectable, Injector, PipeMetadata, Type} from '@angular/core';
|
||||
|
||||
import {PipeResolver} from '../index';
|
||||
import {Map} from '../src/facade/collection';
|
||||
import {Map} from './facade/collection';
|
||||
|
||||
@Injectable()
|
||||
export class MockPipeResolver extends PipeResolver {
|
||||
|
23
modules/@angular/compiler/testing/private_import_core.ts
Normal file
23
modules/@angular/compiler/testing/private_import_core.ts
Normal file
@ -0,0 +1,23 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
|
||||
import {__core_private__ as r} from '@angular/core';
|
||||
|
||||
export type ViewMetadata = typeof r._ViewMetadata;
|
||||
export var ViewMetadata: typeof r.ViewMetadata = r.ViewMetadata;
|
||||
|
||||
|
||||
|
||||
import {__core_private_testing__ as r2} from '@angular/core/testing';
|
||||
|
||||
export type TestingCompiler = typeof r2._TestingCompiler;
|
||||
export var TestingCompiler: typeof r2.TestingCompiler = r2.TestingCompiler;
|
||||
|
||||
export type TestingCompilerFactory = typeof r2._TestingCompilerFactory;
|
||||
export var TestingCompilerFactory: typeof r2.TestingCompilerFactory = r2.TestingCompilerFactory;
|
@ -6,10 +6,10 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {ResourceLoader} from '@angular/compiler';
|
||||
import {ListWrapper, Map} from './facade/collection';
|
||||
import {isBlank, normalizeBlank} from './facade/lang';
|
||||
|
||||
import {ResourceLoader} from '../index';
|
||||
import {ListWrapper, Map} from '../src/facade/collection';
|
||||
import {isBlank, normalizeBlank} from '../src/facade/lang';
|
||||
|
||||
|
||||
/**
|
||||
|
@ -6,10 +6,10 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {ElementSchemaRegistry} from '@angular/compiler';
|
||||
import {SchemaMetadata, SecurityContext} from '@angular/core';
|
||||
|
||||
import {ElementSchemaRegistry} from '../index';
|
||||
import {isPresent} from '../src/facade/lang';
|
||||
import {isPresent} from './facade/lang';
|
||||
|
||||
export class MockSchemaRegistry implements ElementSchemaRegistry {
|
||||
constructor(
|
||||
|
@ -7,11 +7,13 @@
|
||||
*/
|
||||
|
||||
import {ElementSchemaRegistry, ResourceLoader, UrlResolver} from '@angular/compiler';
|
||||
import {createUrlResolverWithoutPackagePrefix} from '@angular/compiler/src/url_resolver';
|
||||
import {MockSchemaRegistry} from '@angular/compiler/testing';
|
||||
import {MockResourceLoader} from '@angular/compiler/testing/resource_loader_mock';
|
||||
import {Provider} from '@angular/core';
|
||||
import {MockResourceLoader} from './resource_loader_mock';
|
||||
import {MockSchemaRegistry} from './schema_registry_mock';
|
||||
|
||||
export function createUrlResolverWithoutPackagePrefix(): UrlResolver {
|
||||
return new UrlResolver();
|
||||
}
|
||||
|
||||
// This provider is put here just so that we can access it from multiple
|
||||
// internal test packages.
|
||||
|
Reference in New Issue
Block a user