diff --git a/modules/@angular/compiler-cli/README.md b/modules/@angular/compiler-cli/README.md index 60971dd4ed..75fa4d97e4 100644 --- a/modules/@angular/compiler-cli/README.md +++ b/modules/@angular/compiler-cli/README.md @@ -119,18 +119,23 @@ At a high level, this program ``` # Build angular2 and the compiler ./build.sh + # Copy over the package so we can test the compiler tests $ cp tools/@angular/tsc-wrapped/package.json dist/tools/@angular/tsc-wrapped + # Run the test once # (First edit the LINKABLE_PKGS to use npm link instead of npm install) $ ./scripts/ci-lite/offline_compiler_test.sh + # Keep a package fresh in watch mode ./node_modules/.bin/tsc -p modules/@angular/compiler/tsconfig-es5.json -w + # Recompile @angular/core module (needs to use tsc-ext to keep the metadata) -export NODE_PATH=${NODE_PATH}:$(pwd)/dist/all:$(pwd)/dist/tools -node dist/tools/@angular/tsc-wrapped/src/main -p modules/@angular/core/tsconfig-es5.json +$ export NODE_PATH=${NODE_PATH}:$(pwd)/dist/all:$(pwd)/dist/tools +$ node dist/tools/@angular/tsc-wrapped/src/main -p modules/@angular/core/tsconfig-es5.json + # Iterate on the test -cd /tmp/wherever/e2e_test.1464388257/ -./node_modules/.bin/ngc -./node_modules/.bin/jasmine test/*_spec.js +$ cd /tmp/wherever/e2e_test.1464388257/ +$ ./node_modules/.bin/ngc +$ ./node_modules/.bin/jasmine test/*_spec.js ``` diff --git a/modules/@angular/compiler-cli/src/codegen.ts b/modules/@angular/compiler-cli/src/codegen.ts index 64d79805aa..d04c3c6f1b 100644 --- a/modules/@angular/compiler-cli/src/codegen.ts +++ b/modules/@angular/compiler-cli/src/codegen.ts @@ -35,8 +35,7 @@ export class CodeGenerator { constructor( private options: AngularCompilerOptions, private program: ts.Program, public host: ts.CompilerHost, private staticReflector: StaticReflector, - private resolver: CompileMetadataResolver, private compiler: compiler.OfflineCompiler, - private reflectorHost: ReflectorHost) {} + private compiler: compiler.OfflineCompiler, private reflectorHost: ReflectorHost) {} private readFileMetadata(absSourcePath: string): FileMetadata { const moduleMetadata = this.staticReflector.getModuleMetadata(absSourcePath); @@ -147,7 +146,7 @@ export class CodeGenerator { new AppModuleCompiler(), new TypeScriptEmitter(reflectorHost)); return new CodeGenerator( - options, program, compilerHost, staticReflector, resolver, offlineCompiler, reflectorHost); + options, program, compilerHost, staticReflector, offlineCompiler, reflectorHost); } } diff --git a/modules/@angular/compiler/src/directive_normalizer.ts b/modules/@angular/compiler/src/directive_normalizer.ts index 1a1f1c7654..5140d9ebbb 100644 --- a/modules/@angular/compiler/src/directive_normalizer.ts +++ b/modules/@angular/compiler/src/directive_normalizer.ts @@ -99,26 +99,26 @@ export class DirectiveNormalizer { normalizeLoadedTemplate( directiveType: CompileTypeMetadata, templateMeta: CompileTemplateMetadata, template: string, templateAbsUrl: string): CompileTemplateMetadata { - var rootNodesAndErrors = this._htmlParser.parse(template, directiveType.name); + const rootNodesAndErrors = this._htmlParser.parse(template, directiveType.name); if (rootNodesAndErrors.errors.length > 0) { - var errorString = rootNodesAndErrors.errors.join('\n'); + const errorString = rootNodesAndErrors.errors.join('\n'); throw new BaseException(`Template parse errors:\n${errorString}`); } - var templateMetadataStyles = this.normalizeStylesheet(new CompileStylesheetMetadata({ + const templateMetadataStyles = this.normalizeStylesheet(new CompileStylesheetMetadata({ styles: templateMeta.styles, styleUrls: templateMeta.styleUrls, moduleUrl: directiveType.moduleUrl })); - var visitor = new TemplatePreparseVisitor(); + const visitor = new TemplatePreparseVisitor(); htmlVisitAll(visitor, rootNodesAndErrors.rootNodes); - var templateStyles = this.normalizeStylesheet(new CompileStylesheetMetadata( + const templateStyles = this.normalizeStylesheet(new CompileStylesheetMetadata( {styles: visitor.styles, styleUrls: visitor.styleUrls, moduleUrl: templateAbsUrl})); - var allStyles = templateMetadataStyles.styles.concat(templateStyles.styles); - var allStyleUrls = templateMetadataStyles.styleUrls.concat(templateStyles.styleUrls); + const allStyles = templateMetadataStyles.styles.concat(templateStyles.styles); + const allStyleUrls = templateMetadataStyles.styleUrls.concat(templateStyles.styleUrls); - var encapsulation = templateMeta.encapsulation; + let encapsulation = templateMeta.encapsulation; if (isBlank(encapsulation)) { encapsulation = this._config.defaultEncapsulation; } diff --git a/modules/@angular/compiler/src/offline_compiler.ts b/modules/@angular/compiler/src/offline_compiler.ts index c09d7a6481..9add04a270 100644 --- a/modules/@angular/compiler/src/offline_compiler.ts +++ b/modules/@angular/compiler/src/offline_compiler.ts @@ -6,8 +6,6 @@ * found in the LICENSE file at https://angular.io/license */ -import {AppModuleMetadata, ComponentMetadata} from '@angular/core'; - import {AppModuleCompiler} from './app_module_compiler'; import {CompileDirectiveMetadata, CompileIdentifierMetadata, CompilePipeMetadata, StaticSymbol, createHostComponentMeta} from './compile_metadata'; import {DirectiveNormalizer} from './directive_normalizer'; @@ -19,9 +17,7 @@ import {OutputEmitter} from './output/abstract_emitter'; import * as o from './output/output_ast'; import {CompiledStylesheet, StyleCompiler} from './style_compiler'; import {TemplateParser} from './template_parser'; -import {assetUrl} from './util'; import {ComponentFactoryDependency, ViewCompileResult, ViewCompiler, ViewFactoryDependency} from './view_compiler/view_compiler'; -import {XHR} from './xhr'; export class SourceModule { constructor(public moduleUrl: string, public source: string) {} diff --git a/modules/@angular/compiler/src/style_compiler.ts b/modules/@angular/compiler/src/style_compiler.ts index 955f2da6cd..db17e4a15d 100644 --- a/modules/@angular/compiler/src/style_compiler.ts +++ b/modules/@angular/compiler/src/style_compiler.ts @@ -7,13 +7,9 @@ */ import {Injectable, ViewEncapsulation} from '@angular/core'; - -import {isPresent} from '../src/facade/lang'; - import {CompileDirectiveMetadata, CompileIdentifierMetadata, CompileStylesheetMetadata} from './compile_metadata'; import * as o from './output/output_ast'; import {ShadowCss} from './shadow_css'; -import {extractStyleUrls} from './style_url_resolver'; import {UrlResolver} from './url_resolver'; const COMPONENT_VARIABLE = '%COMP%'; @@ -46,9 +42,8 @@ export class StyleCompiler { constructor(private _urlResolver: UrlResolver) {} compileComponent(comp: CompileDirectiveMetadata): StylesCompileResult { - var shim = comp.template.encapsulation === ViewEncapsulation.Emulated; - var externalStylesheets: CompiledStylesheet[] = []; - var componentStylesheet: CompiledStylesheet = this._compileStyles( + const externalStylesheets: CompiledStylesheet[] = []; + const componentStylesheet: CompiledStylesheet = this._compileStyles( comp, new CompileStylesheetMetadata({ styles: comp.template.styles, styleUrls: comp.template.styleUrls, @@ -56,7 +51,7 @@ export class StyleCompiler { }), true); comp.template.externalStylesheets.forEach((stylesheetMeta) => { - var compiledStylesheet = this._compileStyles(comp, stylesheetMeta, false); + const compiledStylesheet = this._compileStyles(comp, stylesheetMeta, false); externalStylesheets.push(compiledStylesheet); }); return new StylesCompileResult(componentStylesheet, externalStylesheets); @@ -65,22 +60,22 @@ export class StyleCompiler { private _compileStyles( comp: CompileDirectiveMetadata, stylesheet: CompileStylesheetMetadata, isComponentStylesheet: boolean): CompiledStylesheet { - var shim = comp.template.encapsulation === ViewEncapsulation.Emulated; - var styleExpressions = + const shim = comp.template.encapsulation === ViewEncapsulation.Emulated; + const styleExpressions = stylesheet.styles.map(plainStyle => o.literal(this._shimIfNeeded(plainStyle, shim))); - var dependencies: StylesCompileDependency[] = []; - for (var i = 0; i < stylesheet.styleUrls.length; i++) { - var identifier = new CompileIdentifierMetadata({name: getStylesVarName(null)}); + const dependencies: StylesCompileDependency[] = []; + for (let i = 0; i < stylesheet.styleUrls.length; i++) { + const identifier = new CompileIdentifierMetadata({name: getStylesVarName(null)}); dependencies.push(new StylesCompileDependency(stylesheet.styleUrls[i], shim, identifier)); styleExpressions.push(new o.ExternalExpr(identifier)); } // styles variable contains plain strings and arrays of other styles arrays (recursive), // so we set its type to dynamic. - var stylesVar = getStylesVarName(isComponentStylesheet ? comp : null); - var stmt = o.variable(stylesVar) - .set(o.literalArr( - styleExpressions, new o.ArrayType(o.DYNAMIC_TYPE, [o.TypeModifier.Const]))) - .toDeclStmt(null, [o.StmtModifier.Final]); + const stylesVar = getStylesVarName(isComponentStylesheet ? comp : null); + const stmt = o.variable(stylesVar) + .set(o.literalArr( + styleExpressions, new o.ArrayType(o.DYNAMIC_TYPE, [o.TypeModifier.Const]))) + .toDeclStmt(null, [o.StmtModifier.Final]); return new CompiledStylesheet([stmt], stylesVar, dependencies, shim, stylesheet); } @@ -90,7 +85,7 @@ export class StyleCompiler { } function getStylesVarName(component: CompileDirectiveMetadata): string { - var result = `styles`; + let result = `styles`; if (component) { result += `_${component.type.name}`; }