build: produce metadata bundles for @angular modules (#14509)

Closes #14509
This commit is contained in:
Chuck Jazdzewski 2017-02-15 13:30:40 -08:00 committed by Igor Minar
parent 3b896709a9
commit 724ca373e7
35 changed files with 348 additions and 165 deletions

View File

@ -35,6 +35,7 @@ CLOSURE_ARGS=(
node_modules/zone.js/dist/zone.js node_modules/zone.js/dist/zone.js
$(find -L vendor/rxjs -name *.js) $(find -L vendor/rxjs -name *.js)
node_modules/@angular/{core,common,compiler,platform-browser}/index.js node_modules/@angular/{core,common,compiler,platform-browser}/index.js
node_modules/@angular/{core,common}/public_api.js
$(find node_modules/@angular/{core,common,compiler,platform-browser}/src -name *.js) $(find node_modules/@angular/{core,common,compiler,platform-browser}/src -name *.js)
"built/src/*.js" "built/src/*.js"
"--entry_point=./built/src/main" "--entry_point=./built/src/main"

View File

@ -6,9 +6,9 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
/** // This file is not used to build this module. It is only used during editing
* @module // by the TypeScript language serivce and during build for verifcation. `ngc`
* @description // replaces this file with production index.ts when it rewrites private symbol
* Entry point for all public APIs of the animation package. // names.
*/
export * from './src/animation'; export * from './public_api';

View File

@ -0,0 +1,14 @@
/**
* @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 public APIs of the animation package.
*/
export * from './src/animation';

View File

@ -20,12 +20,14 @@
"types": [] "types": []
}, },
"files": [ "files": [
"index.ts", "public_api.ts",
"../../../node_modules/zone.js/dist/zone.js.d.ts", "../../../node_modules/zone.js/dist/zone.js.d.ts",
"../../system.d.ts" "../../system.d.ts"
], ],
"angularCompilerOptions": { "angularCompilerOptions": {
"annotateForClosureCompiler": true, "annotateForClosureCompiler": true,
"strictMetadataEmit": true "strictMetadataEmit": true,
"bundleIndex": "index",
"importAs": "@angular/animation"
} }
} }

View File

@ -6,11 +6,9 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
/** // This file is not used to build this module. It is only used during editing
* @module // by the TypeScript language serivce and during build for verifcation. `ngc`
* @description // replaces this file with production index.ts when it rewrites private symbol
* Entry point for all public APIs of the common package. // names.
*/
export * from './src/common';
// This file only reexports content of the `src` folder. Keep it that way. export * from './public_api';

View File

@ -0,0 +1,16 @@
/**
* @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 public APIs of the common package.
*/
export * from './src/common';
// This file only reexports content of the `src` folder. Keep it that way.

View File

@ -13,7 +13,7 @@
*/ */
export * from './location/index'; export * from './location/index';
export {NgLocaleLocalization, NgLocalization} from './localization'; export {NgLocaleLocalization, NgLocalization} from './localization';
export {CommonModule} from './common_module'; export {CommonModule, DeprecatedCommonModule} from './common_module';
export {NgClass, NgFor, NgForOf, NgIf, NgPlural, NgPluralCase, NgStyle, NgSwitch, NgSwitchCase, NgSwitchDefault, NgTemplateOutlet, NgComponentOutlet} from './directives/index'; export {NgClass, NgFor, NgForOf, NgIf, NgPlural, NgPluralCase, NgStyle, NgSwitch, NgSwitchCase, NgSwitchDefault, NgTemplateOutlet, NgComponentOutlet} from './directives/index';
export {AsyncPipe, DatePipe, I18nPluralPipe, I18nSelectPipe, JsonPipe, LowerCasePipe, CurrencyPipe, DecimalPipe, PercentPipe, SlicePipe, UpperCasePipe, TitleCasePipe} from './pipes/index'; export {AsyncPipe, DatePipe, I18nPluralPipe, I18nSelectPipe, JsonPipe, LowerCasePipe, CurrencyPipe, DecimalPipe, PercentPipe, SlicePipe, UpperCasePipe, TitleCasePipe} from './pipes/index';
export {VERSION} from './version'; export {VERSION} from './version';

View File

@ -32,7 +32,9 @@ export class CommonModule {
/** /**
* A module to contain deprecated directives. * A module to contain deprecated directives.
*
* @deprecated
*/ */
@NgModule({declarations: [COMMON_DEPRECATED_DIRECTIVES], exports: [COMMON_DEPRECATED_DIRECTIVES]}) @NgModule({declarations: [COMMON_DEPRECATED_DIRECTIVES], exports: [COMMON_DEPRECATED_DIRECTIVES]})
export class CommonDeprecatedModule { export class DeprecatedCommonModule {
} }

View File

@ -20,11 +20,13 @@
"types": [] "types": []
}, },
"files": [ "files": [
"index.ts", "public_api.ts",
"../../../node_modules/zone.js/dist/zone.js.d.ts" "../../../node_modules/zone.js/dist/zone.js.d.ts"
], ],
"angularCompilerOptions": { "angularCompilerOptions": {
"annotateForClosureCompiler": true, "annotateForClosureCompiler": true,
"strictMetadataEmit": true "strictMetadataEmit": true,
"bundleIndex": "index",
"importAs": "@angular/common"
} }
} }

View File

@ -31,8 +31,9 @@ function main() {
class AssertingHostContext extends NodeCompilerHostContext { class AssertingHostContext extends NodeCompilerHostContext {
readFile(fileName: string): string { readFile(fileName: string): string {
if (/.*\/node_modules\/.*/.test(fileName) && !/.*ngsummary\.json$/.test(fileName)) { if (/.*\/node_modules\/.*/.test(fileName) && !/.*ngsummary\.json$/.test(fileName) &&
// Only allow to read summaries from node_modules !/package\.json$/.test(fileName)) {
// Only allow to read summaries and package.json files from node_modules
return null; return null;
} }
readFiles.push(path.relative(basePath, fileName)); readFiles.push(path.relative(basePath, fileName));

View File

@ -17,7 +17,7 @@ import {NgModule} from '@angular/core';
// We cannot depend directly to @angular/router. // We cannot depend directly to @angular/router.
type Route = any; type Route = any;
const ROUTER_MODULE_PATH = '@angular/router/src/router_config_loader'; const ROUTER_MODULE_PATH = '@angular/router';
const ROUTER_ROUTES_SYMBOL_NAME = 'ROUTES'; const ROUTER_ROUTES_SYMBOL_NAME = 'ROUTES';

View File

@ -14,15 +14,7 @@ import {syntaxError} from '../util';
import {StaticSymbol} from './static_symbol'; import {StaticSymbol} from './static_symbol';
import {StaticSymbolResolver} from './static_symbol_resolver'; import {StaticSymbolResolver} from './static_symbol_resolver';
const ANGULAR_IMPORT_LOCATIONS = { const ANGULAR_CORE = '@angular/core';
coreDecorators: '@angular/core/src/metadata',
diDecorators: '@angular/core/src/di/metadata',
diMetadata: '@angular/core/src/di/metadata',
diInjectionToken: '@angular/core/src/di/injection_token',
diOpaqueToken: '@angular/core/src/di/injection_token',
animationMetadata: '@angular/core/src/animation/metadata',
provider: '@angular/core/src/di/provider'
};
const HIDDEN_KEY = /^\$.*\$$/; const HIDDEN_KEY = /^\$.*\$$/;
@ -241,56 +233,53 @@ export class StaticReflector implements ReflectorReader {
} }
private initializeConversionMap(): void { private initializeConversionMap(): void {
const {coreDecorators, diDecorators, diMetadata, diInjectionToken, this.injectionToken = this.findDeclaration(ANGULAR_CORE, 'InjectionToken');
diOpaqueToken, animationMetadata, provider} = ANGULAR_IMPORT_LOCATIONS; this.opaqueToken = this.findDeclaration(ANGULAR_CORE, 'OpaqueToken');
this.injectionToken = this.findDeclaration(diInjectionToken, 'InjectionToken');
this.opaqueToken = this.findDeclaration(diInjectionToken, 'OpaqueToken');
this._registerDecoratorOrConstructor(this.findDeclaration(diDecorators, 'Host'), Host); this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'Host'), Host);
this._registerDecoratorOrConstructor( this._registerDecoratorOrConstructor(
this.findDeclaration(diDecorators, 'Injectable'), Injectable); this.findDeclaration(ANGULAR_CORE, 'Injectable'), Injectable);
this._registerDecoratorOrConstructor(this.findDeclaration(diDecorators, 'Self'), Self); this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'Self'), Self);
this._registerDecoratorOrConstructor(this.findDeclaration(diDecorators, 'SkipSelf'), SkipSelf); this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'SkipSelf'), SkipSelf);
this._registerDecoratorOrConstructor(this.findDeclaration(diDecorators, 'Inject'), Inject); this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'Inject'), Inject);
this._registerDecoratorOrConstructor(this.findDeclaration(diDecorators, 'Optional'), Optional); this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'Optional'), Optional);
this._registerDecoratorOrConstructor( this._registerDecoratorOrConstructor(
this.findDeclaration(coreDecorators, 'Attribute'), Attribute); this.findDeclaration(ANGULAR_CORE, 'Attribute'), Attribute);
this._registerDecoratorOrConstructor( this._registerDecoratorOrConstructor(
this.findDeclaration(coreDecorators, 'ContentChild'), ContentChild); this.findDeclaration(ANGULAR_CORE, 'ContentChild'), ContentChild);
this._registerDecoratorOrConstructor( this._registerDecoratorOrConstructor(
this.findDeclaration(coreDecorators, 'ContentChildren'), ContentChildren); this.findDeclaration(ANGULAR_CORE, 'ContentChildren'), ContentChildren);
this._registerDecoratorOrConstructor( this._registerDecoratorOrConstructor(
this.findDeclaration(coreDecorators, 'ViewChild'), ViewChild); this.findDeclaration(ANGULAR_CORE, 'ViewChild'), ViewChild);
this._registerDecoratorOrConstructor( this._registerDecoratorOrConstructor(
this.findDeclaration(coreDecorators, 'ViewChildren'), ViewChildren); this.findDeclaration(ANGULAR_CORE, 'ViewChildren'), ViewChildren);
this._registerDecoratorOrConstructor(this.findDeclaration(coreDecorators, 'Input'), Input); this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'Input'), Input);
this._registerDecoratorOrConstructor(this.findDeclaration(coreDecorators, 'Output'), Output); this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'Output'), Output);
this._registerDecoratorOrConstructor(this.findDeclaration(coreDecorators, 'Pipe'), Pipe); this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'Pipe'), Pipe);
this._registerDecoratorOrConstructor( this._registerDecoratorOrConstructor(
this.findDeclaration(coreDecorators, 'HostBinding'), HostBinding); this.findDeclaration(ANGULAR_CORE, 'HostBinding'), HostBinding);
this._registerDecoratorOrConstructor( this._registerDecoratorOrConstructor(
this.findDeclaration(coreDecorators, 'HostListener'), HostListener); this.findDeclaration(ANGULAR_CORE, 'HostListener'), HostListener);
this._registerDecoratorOrConstructor( this._registerDecoratorOrConstructor(
this.findDeclaration(coreDecorators, 'Directive'), Directive); this.findDeclaration(ANGULAR_CORE, 'Directive'), Directive);
this._registerDecoratorOrConstructor( this._registerDecoratorOrConstructor(
this.findDeclaration(coreDecorators, 'Component'), Component); this.findDeclaration(ANGULAR_CORE, 'Component'), Component);
this._registerDecoratorOrConstructor( this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'NgModule'), NgModule);
this.findDeclaration(coreDecorators, 'NgModule'), NgModule);
// Note: Some metadata classes can be used directly with Provider.deps. // Note: Some metadata classes can be used directly with Provider.deps.
this._registerDecoratorOrConstructor(this.findDeclaration(diMetadata, 'Host'), Host); this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'Host'), Host);
this._registerDecoratorOrConstructor(this.findDeclaration(diMetadata, 'Self'), Self); this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'Self'), Self);
this._registerDecoratorOrConstructor(this.findDeclaration(diMetadata, 'SkipSelf'), SkipSelf); this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'SkipSelf'), SkipSelf);
this._registerDecoratorOrConstructor(this.findDeclaration(diMetadata, 'Optional'), Optional); this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'Optional'), Optional);
this._registerFunction(this.findDeclaration(animationMetadata, 'trigger'), trigger); this._registerFunction(this.findDeclaration(ANGULAR_CORE, 'trigger'), trigger);
this._registerFunction(this.findDeclaration(animationMetadata, 'state'), state); this._registerFunction(this.findDeclaration(ANGULAR_CORE, 'state'), state);
this._registerFunction(this.findDeclaration(animationMetadata, 'transition'), transition); this._registerFunction(this.findDeclaration(ANGULAR_CORE, 'transition'), transition);
this._registerFunction(this.findDeclaration(animationMetadata, 'style'), style); this._registerFunction(this.findDeclaration(ANGULAR_CORE, 'style'), style);
this._registerFunction(this.findDeclaration(animationMetadata, 'animate'), animate); this._registerFunction(this.findDeclaration(ANGULAR_CORE, 'animate'), animate);
this._registerFunction(this.findDeclaration(animationMetadata, 'keyframes'), keyframes); this._registerFunction(this.findDeclaration(ANGULAR_CORE, 'keyframes'), keyframes);
this._registerFunction(this.findDeclaration(animationMetadata, 'sequence'), sequence); this._registerFunction(this.findDeclaration(ANGULAR_CORE, 'sequence'), sequence);
this._registerFunction(this.findDeclaration(animationMetadata, 'group'), group); this._registerFunction(this.findDeclaration(ANGULAR_CORE, 'group'), group);
} }
/** /**

View File

@ -202,9 +202,16 @@ export class StaticSymbolResolver {
new Set<string>(Object.keys(metadata['metadata']).map(unescapeIdentifier)); new Set<string>(Object.keys(metadata['metadata']).map(unescapeIdentifier));
Object.keys(metadata['metadata']).forEach((metadataKey) => { Object.keys(metadata['metadata']).forEach((metadataKey) => {
const symbolMeta = metadata['metadata'][metadataKey]; const symbolMeta = metadata['metadata'][metadataKey];
resolvedSymbols.push(this.createResolvedSymbol( const name = unescapeIdentifier(metadataKey);
this.getStaticSymbol(filePath, unescapeIdentifier(metadataKey)), topLevelSymbolNames, const canonicalSymbol = this.getStaticSymbol(filePath, name);
symbolMeta)); if (metadata['importAs']) {
// Index bundle indexes should use the importAs module name instead of a reference
// to the .d.ts file directly.
const importSymbol = this.getStaticSymbol(metadata['importAs'], name);
this.recordImportAs(canonicalSymbol, importSymbol);
}
resolvedSymbols.push(
this.createResolvedSymbol(canonicalSymbol, topLevelSymbolNames, symbolMeta));
}); });
} }
@ -372,7 +379,7 @@ export class StaticSymbolResolver {
return this.host.moduleNameToFileName(module, containingFile); return this.host.moduleNameToFileName(module, containingFile);
} catch (e) { } catch (e) {
console.error(`Could not resolve module '${module}' relative to file ${containingFile}`); console.error(`Could not resolve module '${module}' relative to file ${containingFile}`);
this.reportError(new e, null, containingFile); this.reportError(e, null, containingFile);
} }
} }
} }

View File

@ -9,15 +9,18 @@
import {AotCompiler, AotCompilerHost, createAotCompiler} from '@angular/compiler'; import {AotCompiler, AotCompilerHost, createAotCompiler} from '@angular/compiler';
import {RenderComponentType} from '@angular/core'; import {RenderComponentType} from '@angular/core';
import {async} from '@angular/core/testing'; import {async} from '@angular/core/testing';
import {MetadataBundler, MetadataCollector, ModuleMetadata, privateEntriesToIndex} from '@angular/tsc-wrapped';
import * as path from 'path'; import * as path from 'path';
import * as ts from 'typescript'; import * as ts from 'typescript';
import {ReflectionCapabilities, reflector} from './private_import_core'; import {ReflectionCapabilities, reflector} from './private_import_core';
import {EmittingCompilerHost, MockAotCompilerHost, MockCompilerHost, MockData, settings} from './test_util'; import {EmittingCompilerHost, MockAotCompilerHost, MockCompilerHost, MockData, MockMetadataBundlerHost, settings} from './test_util';
const DTS = /\.d\.ts$/; const DTS = /\.d\.ts$/;
const minCoreIndex = ` const minCoreIndex = `
export * from './src/application_module';
export * from './src/change_detection';
export * from './src/metadata'; export * from './src/metadata';
export * from './src/di/metadata'; export * from './src/di/metadata';
export * from './src/di/injector'; export * from './src/di/injector';
@ -28,7 +31,7 @@ const minCoreIndex = `
export * from './src/codegen_private_exports'; export * from './src/codegen_private_exports';
`; `;
describe('compiler', () => { describe('compiler (unbundled Angular)', () => {
let angularFiles: Map<string, string>; let angularFiles: Map<string, string>;
beforeAll(() => { beforeAll(() => {
@ -55,17 +58,64 @@ describe('compiler', () => {
it('should compile', it('should compile',
async(() => compile(host, aotHost, expectNoDiagnostics).then(generatedFiles => { async(() => compile(host, aotHost, expectNoDiagnostics).then(generatedFiles => {
expect(generatedFiles.find(f => /app\.component\.ngfactory\.ts/.test(f.genFileUrl))) expect(generatedFiles.find(f => /app\.component\.ngfactory\.ts/.test(f.genFileUrl)))
.not.toBeUndefined(); .toBeDefined();
expect(generatedFiles.find(f => /app\.module\.ngfactory\.ts/.test(f.genFileUrl))) expect(generatedFiles.find(f => /app\.module\.ngfactory\.ts/.test(f.genFileUrl)))
.not.toBeUndefined(); .toBeDefined();
}))); })));
it('should compile using summaries', it('should compile using summaries',
async(() => summaryCompile(host, aotHost).then(generatedFiles => { async(() => summaryCompile(host, aotHost).then(generatedFiles => {
expect(generatedFiles.find(f => /app\.component\.ngfactory\.ts/.test(f.genFileUrl))) expect(generatedFiles.find(f => /app\.component\.ngfactory\.ts/.test(f.genFileUrl)))
.not.toBeUndefined(); .toBeDefined();
expect(generatedFiles.find(f => /app\.module\.ngfactory\.ts/.test(f.genFileUrl))) expect(generatedFiles.find(f => /app\.module\.ngfactory\.ts/.test(f.genFileUrl)))
.not.toBeUndefined(); .toBeDefined();
})));
});
});
describe('compiler (bundled Angular)', () => {
let angularFiles: Map<string, string>;
beforeAll(() => {
const emittingHost = new EmittingCompilerHost(['@angular/core/index'], {emitMetadata: false});
// Create the metadata bundled
const indexModule = emittingHost.effectiveName('@angular/core/index');
const bundler = new MetadataBundler(
indexModule, '@angular/core', new MockMetadataBundlerHost(emittingHost));
const bundle = bundler.getMetadataBundle();
const metadata = JSON.stringify(bundle.metadata, null, ' ');
const bundleIndexSource = privateEntriesToIndex('./index', bundle.privates);
emittingHost.override('@angular/core/bundle_index.ts', bundleIndexSource);
emittingHost.addWrittenFile(
'@angular/core/package.json', JSON.stringify({typings: 'bundle_index.d.ts'}));
emittingHost.addWrittenFile('@angular/core/bundle_index.metadata.json', metadata);
// Emit the sources
const bundleIndexName = emittingHost.effectiveName('@angular/core/bundle_index.ts');
const emittingProgram = ts.createProgram([bundleIndexName], settings, emittingHost);
emittingProgram.emit();
angularFiles = emittingHost.written;
});
describe('Quickstart', () => {
let host: MockCompilerHost;
let aotHost: MockAotCompilerHost;
beforeEach(() => {
host = new MockCompilerHost(QUICKSTART, FILES, angularFiles);
aotHost = new MockAotCompilerHost(host);
});
// Restore reflector since AoT compiler will update it with a new static reflector
afterEach(() => { reflector.updateCapabilities(new ReflectionCapabilities()); });
it('should compile',
async(() => compile(host, aotHost, expectNoDiagnostics).then(generatedFiles => {
expect(generatedFiles.find(f => /app\.component\.ngfactory\.ts/.test(f.genFileUrl)))
.toBeDefined();
expect(generatedFiles.find(f => /app\.module\.ngfactory\.ts/.test(f.genFileUrl)))
.toBeDefined();
}))); })));
}); });
}); });

View File

@ -44,14 +44,10 @@ describe('StaticReflector', () => {
it('should get constructor for NgFor', () => { it('should get constructor for NgFor', () => {
const NgFor = reflector.findDeclaration('@angular/common/src/directives/ng_for', 'NgFor'); const NgFor = reflector.findDeclaration('@angular/common/src/directives/ng_for', 'NgFor');
const ViewContainerRef = reflector.findDeclaration( const ViewContainerRef = reflector.findDeclaration('@angular/core', 'ViewContainerRef');
'@angular/core/src/linker/view_container_ref', 'ViewContainerRef'); const TemplateRef = reflector.findDeclaration('@angular/core', 'TemplateRef');
const TemplateRef = const IterableDiffers = reflector.findDeclaration('@angular/core', 'IterableDiffers');
reflector.findDeclaration('@angular/core/src/linker/template_ref', 'TemplateRef'); const ChangeDetectorRef = reflector.findDeclaration('@angular/core', 'ChangeDetectorRef');
const IterableDiffers = reflector.findDeclaration(
'@angular/core/src/change_detection/differs/iterable_differs', 'IterableDiffers');
const ChangeDetectorRef = reflector.findDeclaration(
'@angular/core/src/change_detection/change_detector_ref', 'ChangeDetectorRef');
const parameters = reflector.parameters(NgFor); const parameters = reflector.parameters(NgFor);
expect(parameters).toEqual([ expect(parameters).toEqual([
@ -732,7 +728,7 @@ const DEFAULT_TEST_DATA: {[key: string]: any} = {
'expression': { 'expression': {
'__symbolic': 'reference', '__symbolic': 'reference',
'name': 'Directive', 'name': 'Directive',
'module': '@angular/core/src/metadata' 'module': '@angular/core'
}, },
'arguments': [ 'arguments': [
{ {
@ -749,22 +745,22 @@ const DEFAULT_TEST_DATA: {[key: string]: any} = {
'parameters': [ 'parameters': [
{ {
'__symbolic': 'reference', '__symbolic': 'reference',
'module': '@angular/core/src/linker/view_container_ref', 'module': '@angular/core',
'name': 'ViewContainerRef' 'name': 'ViewContainerRef'
}, },
{ {
'__symbolic': 'reference', '__symbolic': 'reference',
'module': '@angular/core/src/linker/template_ref', 'module': '@angular/core',
'name': 'TemplateRef' 'name': 'TemplateRef'
}, },
{ {
'__symbolic': 'reference', '__symbolic': 'reference',
'module': '@angular/core/src/change_detection/differs/iterable_differs', 'module': '@angular/core',
'name': 'IterableDiffers' 'name': 'IterableDiffers'
}, },
{ {
'__symbolic': 'reference', '__symbolic': 'reference',
'module': '@angular/core/src/change_detection/change_detector_ref', 'module': '@angular/core',
'name': 'ChangeDetectorRef' 'name': 'ChangeDetectorRef'
} }
] ]
@ -794,7 +790,7 @@ const DEFAULT_TEST_DATA: {[key: string]: any} = {
'expression': { 'expression': {
'__symbolic': 'reference', '__symbolic': 'reference',
'name': 'Component', 'name': 'Component',
'module': '@angular/core/src/metadata' 'module': '@angular/core'
}, },
'arguments': [ 'arguments': [
{ {
@ -806,7 +802,7 @@ const DEFAULT_TEST_DATA: {[key: string]: any} = {
'expression': { 'expression': {
'__symbolic': 'reference', '__symbolic': 'reference',
'name': 'trigger', 'name': 'trigger',
'module': '@angular/core/src/animation/metadata' 'module': '@angular/core'
}, },
'arguments': [ 'arguments': [
'myAnimation', 'myAnimation',
@ -814,7 +810,7 @@ const DEFAULT_TEST_DATA: {[key: string]: any} = {
'expression': { 'expression': {
'__symbolic': 'reference', '__symbolic': 'reference',
'name': 'state', 'name': 'state',
'module': '@angular/core/src/animation/metadata' 'module': '@angular/core'
}, },
'arguments': [ 'arguments': [
'state1', 'state1',
@ -822,7 +818,7 @@ const DEFAULT_TEST_DATA: {[key: string]: any} = {
'expression': { 'expression': {
'__symbolic': 'reference', '__symbolic': 'reference',
'name': 'style', 'name': 'style',
'module': '@angular/core/src/animation/metadata' 'module': '@angular/core'
}, },
'arguments': [ 'arguments': [
{ 'background':'white' } { 'background':'white' }
@ -834,7 +830,7 @@ const DEFAULT_TEST_DATA: {[key: string]: any} = {
'expression': { 'expression': {
'__symbolic':'reference', '__symbolic':'reference',
'name':'transition', 'name':'transition',
'module': '@angular/core/src/animation/metadata' 'module': '@angular/core'
}, },
'arguments': [ 'arguments': [
'* => *', '* => *',
@ -843,20 +839,20 @@ const DEFAULT_TEST_DATA: {[key: string]: any} = {
'expression':{ 'expression':{
'__symbolic':'reference', '__symbolic':'reference',
'name':'sequence', 'name':'sequence',
'module': '@angular/core/src/animation/metadata' 'module': '@angular/core'
}, },
'arguments':[[{ '__symbolic': 'call', 'arguments':[[{ '__symbolic': 'call',
'expression': { 'expression': {
'__symbolic':'reference', '__symbolic':'reference',
'name':'group', 'name':'group',
'module': '@angular/core/src/animation/metadata' 'module': '@angular/core'
}, },
'arguments':[[{ 'arguments':[[{
'__symbolic': 'call', '__symbolic': 'call',
'expression': { 'expression': {
'__symbolic':'reference', '__symbolic':'reference',
'name':'animate', 'name':'animate',
'module': '@angular/core/src/animation/metadata' 'module': '@angular/core'
}, },
'arguments':[ 'arguments':[
'1s 0.5s', '1s 0.5s',
@ -864,13 +860,13 @@ const DEFAULT_TEST_DATA: {[key: string]: any} = {
'expression': { 'expression': {
'__symbolic':'reference', '__symbolic':'reference',
'name':'keyframes', 'name':'keyframes',
'module': '@angular/core/src/animation/metadata' 'module': '@angular/core'
}, },
'arguments':[[{ '__symbolic': 'call', 'arguments':[[{ '__symbolic': 'call',
'expression': { 'expression': {
'__symbolic':'reference', '__symbolic':'reference',
'name':'style', 'name':'style',
'module': '@angular/core/src/animation/metadata' 'module': '@angular/core'
}, },
'arguments':[ { 'background': 'blue'} ] 'arguments':[ { 'background': 'blue'} ]
}, { }, {
@ -878,7 +874,7 @@ const DEFAULT_TEST_DATA: {[key: string]: any} = {
'expression': { 'expression': {
'__symbolic':'reference', '__symbolic':'reference',
'name':'style', 'name':'style',
'module': '@angular/core/src/animation/metadata' 'module': '@angular/core'
}, },
'arguments':[ { 'background': 'red'} ] 'arguments':[ { 'background': 'red'} ]
}]] }]]
@ -904,7 +900,7 @@ const DEFAULT_TEST_DATA: {[key: string]: any} = {
'expression': { 'expression': {
'__symbolic': 'reference', '__symbolic': 'reference',
'name': 'Input', 'name': 'Input',
'module': '@angular/core/src/metadata' 'module': '@angular/core'
} }
} }
] ]
@ -918,7 +914,7 @@ const DEFAULT_TEST_DATA: {[key: string]: any} = {
'__symbolic': 'call', '__symbolic': 'call',
'expression': { 'expression': {
'__symbolic': 'reference', '__symbolic': 'reference',
'module': '@angular/core/src/metadata', 'module': '@angular/core',
'name': 'HostListener' 'name': 'HostListener'
}, },
'arguments': [ 'arguments': [
@ -948,7 +944,7 @@ const DEFAULT_TEST_DATA: {[key: string]: any} = {
expression: { expression: {
__symbolic: 'reference', __symbolic: 'reference',
name: 'Component', name: 'Component',
module: '@angular/core/src/metadata' module: '@angular/core'
}, },
arguments: [ arguments: [
{ {
@ -1149,7 +1145,7 @@ const DEFAULT_TEST_DATA: {[key: string]: any} = {
`, `,
'/tmp/src/invalid-calls.ts': ` '/tmp/src/invalid-calls.ts': `
import {someFunction} from './nvalid-calll-definitions.ts'; import {someFunction} from './nvalid-calll-definitions.ts';
import {Component} from '@angular/core/src/metadata'; import {Component} from '@angular/core';
import {NgIf} from '@angular/common'; import {NgIf} from '@angular/common';
@Component({ @Component({
@ -1193,7 +1189,7 @@ const DEFAULT_TEST_DATA: {[key: string]: any} = {
} }
`, `,
'/tmp/src/static-method-call.ts': ` '/tmp/src/static-method-call.ts': `
import {Component} from '@angular/core/src/metadata'; import {Component} from '@angular/core';
import {MyModule} from './static-method'; import {MyModule} from './static-method';
@Component({ @Component({
@ -1225,7 +1221,7 @@ const DEFAULT_TEST_DATA: {[key: string]: any} = {
} }
`, `,
'/tmp/src/static-field-reference.ts': ` '/tmp/src/static-field-reference.ts': `
import {Component} from '@angular/core/src/metadata'; import {Component} from '@angular/core';
import {MyModule} from './static-field'; import {MyModule} from './static-field';
@Component({ @Component({
@ -1239,7 +1235,7 @@ const DEFAULT_TEST_DATA: {[key: string]: any} = {
} }
`, `,
'/tmp/src/static-method-ref.ts': ` '/tmp/src/static-method-ref.ts': `
import {Component} from '@angular/core/src/metadata'; import {Component} from '@angular/core';
import {ClassWithStatics} from './static-method-def'; import {ClassWithStatics} from './static-method-def';
@Component({ @Component({
@ -1250,7 +1246,7 @@ const DEFAULT_TEST_DATA: {[key: string]: any} = {
} }
`, `,
'/tmp/src/invalid-metadata.ts': ` '/tmp/src/invalid-metadata.ts': `
import {Component} from '@angular/core/src/metadata'; import {Component} from '@angular/core';
@Component({ @Component({
providers: [ { provider: 'a', useValue: (() => 1)() }] providers: [ { provider: 'a', useValue: (() => 1)() }]
@ -1259,8 +1255,8 @@ const DEFAULT_TEST_DATA: {[key: string]: any} = {
`, `,
'/tmp/src/forward-ref.ts': ` '/tmp/src/forward-ref.ts': `
import {forwardRef} from '@angular/core'; import {forwardRef} from '@angular/core';
import {Component} from '@angular/core/src/metadata'; import {Component} from '@angular/core';
import {Inject} from '@angular/core/src/di/metadata'; import {Inject} from '@angular/core';
@Component({}) @Component({})
export class Forward { export class Forward {
constructor(@Inject(forwardRef(() => Dep)) d: Dep) {} constructor(@Inject(forwardRef(() => Dep)) d: Dep) {}

View File

@ -7,7 +7,7 @@
*/ */
import {AotCompilerHost} from '@angular/compiler'; import {AotCompilerHost} from '@angular/compiler';
import {MetadataCollector} from '@angular/tsc-wrapped'; import {MetadataBundlerHost, MetadataCollector, ModuleMetadata} from '@angular/tsc-wrapped';
import * as fs from 'fs'; import * as fs from 'fs';
import * as path from 'path'; import * as path from 'path';
import * as ts from 'typescript'; import * as ts from 'typescript';
@ -216,12 +216,15 @@ export class MockCompilerHost implements ts.CompilerHost {
} }
const effectiveName = this.getEffectiveName(fileName); const effectiveName = this.getEffectiveName(fileName);
if (effectiveName == fileName) { if (effectiveName == fileName) {
return open(fileName, this.data) != null; let result = open(fileName, this.data) != null;
return result;
} else { } else {
if (fileName.match(rxjs)) { if (fileName.match(rxjs)) {
return fs.existsSync(effectiveName); let result = fs.existsSync(effectiveName);
return result;
} }
return this.angular.has(effectiveName); let result = this.angular.has(effectiveName);
return result;
} }
} }
@ -389,6 +392,17 @@ export class MockAotCompilerHost implements AotCompilerHost {
} }
} }
export class MockMetadataBundlerHost implements MetadataBundlerHost {
private collector = new MetadataCollector();
constructor(private host: ts.CompilerHost) {}
getMetadataFor(moduleName: string): ModuleMetadata {
const source = this.host.getSourceFile(moduleName + '.ts', ts.ScriptTarget.Latest);
return this.collector.getMetadata(source);
}
}
function find(fileName: string, data: MockData): MockData|undefined { function find(fileName: string, data: MockData): MockData|undefined {
let names = fileName.split('/'); let names = fileName.split('/');
if (names.length && !names[0].length) names.shift(); if (names.length && !names[0].length) names.shift();

View File

@ -6,11 +6,9 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
/** // This file is not used to build this module. It is only used during editing
* @module // by the TypeScript language serivce and during build for verifcation. `ngc`
* @description // replaces this file with production index.ts when it rewrites private symbol
* Entry point for all public APIs of the core package. // names.
*/
export * from './src/core';
// This file only reexports content of the `src` folder. Keep it that way. export * from './public_api';

View File

@ -0,0 +1,16 @@
/**
* @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 public APIs of the core package.
*/
export * from './src/core';
// This file only reexports content of the `src` folder. Keep it that way.

View File

@ -20,12 +20,14 @@
"types": [] "types": []
}, },
"files": [ "files": [
"index.ts", "public_api.ts",
"../../../node_modules/zone.js/dist/zone.js.d.ts", "../../../node_modules/zone.js/dist/zone.js.d.ts",
"../../system.d.ts" "../../system.d.ts"
], ],
"angularCompilerOptions": { "angularCompilerOptions": {
"annotateForClosureCompiler": true, "annotateForClosureCompiler": true,
"strictMetadataEmit": true "strictMetadataEmit": true,
"bundleIndex": "index",
"importAs": "@angular/core"
} }
} }

View File

@ -6,11 +6,9 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
/** // This file is not used to build this module. It is only used during editing
* @module // by the TypeScript language serivce and during build for verifcation. `ngc`
* @description // replaces this file with production index.ts when it rewrites private symbol
* Entry point for all public APIs of the forms package. // names.
*/
export * from './src/forms';
// This file only reexports content of the `src` folder. Keep it that way. export * from './public_api';

View File

@ -0,0 +1,16 @@
/**
* @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 public APIs of the forms package.
*/
export * from './src/forms';
// This file only reexports content of the `src` folder. Keep it that way.

View File

@ -25,11 +25,13 @@
"types": [] "types": []
}, },
"files": [ "files": [
"index.ts", "public_api.ts",
"../../../node_modules/zone.js/dist/zone.js.d.ts" "../../../node_modules/zone.js/dist/zone.js.d.ts"
], ],
"angularCompilerOptions": { "angularCompilerOptions": {
"annotateForClosureCompiler": true, "annotateForClosureCompiler": true,
"strictMetadataEmit": true "strictMetadataEmit": true,
"bundleIndex": "index",
"importAs": "@angular/forms"
} }
} }

View File

@ -6,11 +6,9 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
/** // This file is not used to build this module. It is only used during editing
* @module // by the TypeScript language serivce and during build for verifcation. `ngc`
* @description // replaces this file with production index.ts when it rewrites private symbol
* Entry point for all public APIs of the http package. // names.
*/
export * from './src/index';
// This file only reexports content of the `src` folder. Keep it that way. export * from './public_api';

View File

@ -0,0 +1,16 @@
/**
* @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 public APIs of the http package.
*/
export * from './src/index';
// This file only reexports content of the `src` folder. Keep it that way.

View File

@ -20,11 +20,13 @@
"lib": ["es2015", "dom"] "lib": ["es2015", "dom"]
}, },
"files": [ "files": [
"index.ts", "public_api.ts",
"../../../node_modules/zone.js/dist/zone.js.d.ts" "../../../node_modules/zone.js/dist/zone.js.d.ts"
], ],
"angularCompilerOptions": { "angularCompilerOptions": {
"annotateForClosureCompiler": true, "annotateForClosureCompiler": true,
"strictMetadataEmit": true "strictMetadataEmit": true,
"bundleIndex": "index",
"importAs": "@angular/http"
} }
} }

View File

@ -6,11 +6,9 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
/** // This file is not used to build this module. It is only used during editing
* @module // by the TypeScript language serivce and during build for verifcation. `ngc`
* @description // replaces this file with production index.ts when it rewrites private symbol
* Entry point for all public APIs of the router package. // names.
*/
export * from './src/index';
// This file only reexports content of the `src` folder. Keep it that way. export * from './public_api';

View File

@ -0,0 +1,16 @@
/**
* @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 public APIs of the router package.
*/
export * from './src/index';
// This file only reexports content of the `src` folder. Keep it that way.

View File

@ -14,6 +14,7 @@ export {RouterOutlet} from './directives/router_outlet';
export {CanActivate, CanActivateChild, CanDeactivate, CanLoad, Resolve} from './interfaces'; export {CanActivate, CanActivateChild, CanDeactivate, CanLoad, Resolve} from './interfaces';
export {DetachedRouteHandle, RouteReuseStrategy} from './route_reuse_strategy'; export {DetachedRouteHandle, RouteReuseStrategy} from './route_reuse_strategy';
export {Event, NavigationCancel, NavigationEnd, NavigationError, NavigationExtras, NavigationStart, Router, RoutesRecognized} from './router'; export {Event, NavigationCancel, NavigationEnd, NavigationError, NavigationExtras, NavigationStart, Router, RoutesRecognized} from './router';
export {ROUTES} from './router_config_loader';
export {ExtraOptions, ROUTER_CONFIGURATION, ROUTER_INITIALIZER, RouterModule, provideRoutes} from './router_module'; export {ExtraOptions, ROUTER_CONFIGURATION, ROUTER_INITIALIZER, RouterModule, provideRoutes} from './router_module';
export {RouterOutletMap} from './router_outlet_map'; export {RouterOutletMap} from './router_outlet_map';
export {NoPreloading, PreloadAllModules, PreloadingStrategy, RouterPreloader} from './router_preloader'; export {NoPreloading, PreloadAllModules, PreloadingStrategy, RouterPreloader} from './router_preloader';
@ -22,4 +23,5 @@ export {PRIMARY_OUTLET, Params} from './shared';
export {UrlHandlingStrategy} from './url_handling_strategy'; export {UrlHandlingStrategy} from './url_handling_strategy';
export {DefaultUrlSerializer, UrlSegment, UrlSegmentGroup, UrlSerializer, UrlTree} from './url_tree'; export {DefaultUrlSerializer, UrlSegment, UrlSegmentGroup, UrlSerializer, UrlTree} from './url_tree';
export {VERSION} from './version'; export {VERSION} from './version';
export * from './private_export' export * from './private_export'

View File

@ -18,6 +18,7 @@ import {flatten, wrapIntoObservable} from './utils/collection';
/** /**
* @docsNotRequired
* @experimental * @experimental
*/ */
export const ROUTES = new InjectionToken<Route[][]>('ROUTES'); export const ROUTES = new InjectionToken<Route[][]>('ROUTES');

View File

@ -24,10 +24,12 @@
"skipLibCheck": true "skipLibCheck": true
}, },
"files": [ "files": [
"index.ts" "public_api.ts"
], ],
"angularCompilerOptions": { "angularCompilerOptions": {
"annotateForClosureCompiler": true, "annotateForClosureCompiler": true,
"strictMetadataEmit": true "strictMetadataEmit": true,
"bundleIndex": "index",
"importAs": "@angular/router"
} }
} }

View File

@ -0,0 +1,21 @@
/**
* @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 public APIs of the upgrade/static package, allowing
* Angular 1 and Angular 2+ to run side by side in the same application.
*/
export {downgradeComponent} from './src/common/downgrade_component';
export {downgradeInjectable} from './src/common/downgrade_injectable';
export {VERSION} from './src/common/version';
export {UpgradeComponent} from './src/static/upgrade_component';
export {UpgradeModule} from './src/static/upgrade_module';
// This file only re-exports content of the `src` folder. Keep it that way.

View File

@ -6,16 +6,9 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
/** // This file is not used to build this module. It is only used during editing
* @module // by the TypeScript language serivce and during build for verifcation. `ngc`
* @description // replaces this file with production static.ts when it rewrites private symbol
* Entry point for all public APIs of the upgrade/static package, allowing // names.
* Angular 1 and Angular 2+ to run side by side in the same application.
*/
export {downgradeComponent} from './src/common/downgrade_component';
export {downgradeInjectable} from './src/common/downgrade_injectable';
export {VERSION} from './src/common/version';
export {UpgradeComponent} from './src/static/upgrade_component';
export {UpgradeModule} from './src/static/upgrade_module';
// This file only re-exports content of the `src` folder. Keep it that way. export * from './public_api_static';

View File

@ -24,12 +24,15 @@
"types": [] "types": []
}, },
"files": [ "files": [
"public_api_static.ts",
"index.ts", "index.ts",
"static.ts",
"../../../node_modules/zone.js/dist/zone.js.d.ts" "../../../node_modules/zone.js/dist/zone.js.d.ts"
], ],
"angularCompilerOptions": { "angularCompilerOptions": {
"annotateForClosureCompiler": true, "annotateForClosureCompiler": true,
"strictMetadataEmit": true "strictMetadataEmit": true,
"bundleIndex": "static",
"libraryIndex": "./public_api_static",
"importAs": "@angular/upgrade/static"
} }
} }

View File

@ -32,6 +32,10 @@ export declare class DecimalPipe implements PipeTransform {
transform(value: any, digits?: string): string; transform(value: any, digits?: string): string;
} }
/** @deprecated */
export declare class DeprecatedCommonModule {
}
/** @stable */ /** @stable */
export declare class HashLocationStrategy extends LocationStrategy { export declare class HashLocationStrategy extends LocationStrategy {
constructor(_platformLocation: PlatformLocation, _baseHref?: string); constructor(_platformLocation: PlatformLocation, _baseHref?: string);

View File

@ -345,6 +345,9 @@ export declare class RouterStateSnapshot extends Tree<ActivatedRouteSnapshot> {
/** @stable */ /** @stable */
export declare type Routes = Route[]; export declare type Routes = Route[];
/** @experimental */
export declare const ROUTES: InjectionToken<Route[][]>;
/** @stable */ /** @stable */
export declare class RoutesRecognized { export declare class RoutesRecognized {
id: number; id: number;