diff --git a/BUILD b/BUILD index 75675f5346..fe62b84a90 100644 --- a/BUILD +++ b/BUILD @@ -219,6 +219,41 @@ ts_library( module_name = "@angular/compiler/test", ) +nodejs_binary( + name = "compiler_test_codegen_bin", + srcs = [":compiler_test_module"], + deps = [ + "reflect-metadata", + ], + entry_point = "modules/@angular/compiler/test/output/output_emitter_codegen.js", +) + +genrule( + name = "compiler_test_codegen_ts", + outs = [ + "modules/@angular/compiler/test/output/output_emitter_generated_typed.ts", + "modules/@angular/compiler/test/output/output_emitter_generated_untyped.ts", + ], + tools = [ + # This has to be put in tools so that its runfiles tree is also built. + ":compiler_test_codegen_bin", + ], + cmd = "$(location :compiler_test_codegen_bin) --node_path=modules/ $(OUTS)", + output_to_bindir = True, +) + +ts_library( + name = "compiler_test_codegen_js", + srcs = [":compiler_test_codegen_ts"], + deps = [ + ":core", + ":compiler", + ":compiler_test_module", + ], + tsconfig = "tools/cjs-jasmine/tsconfig-output_emitter_codegen.json", + root_dir = "modules/@angular/compiler/test", +) + ts_library( name = "core", srcs = glob( @@ -539,7 +574,7 @@ ts_library( jasmine_node_test( name = "compiler_test", - srcs = [":compiler_test_module"], + srcs = [":compiler_test_module", ":compiler_test_codegen_js"], helpers = [":jasmine_helper"], size = "small", args = ["--node_path=modules:tools"], diff --git a/modules/@angular/compiler/test/output/output_emitter_codegen.ts b/modules/@angular/compiler/test/output/output_emitter_codegen.ts new file mode 100644 index 0000000000..834559f12e --- /dev/null +++ b/modules/@angular/compiler/test/output/output_emitter_codegen.ts @@ -0,0 +1,26 @@ +/** + * @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 'reflect-metadata'; + +import {writeFileSync} from 'fs'; + +import {emit as typedEmit} from './output_emitter_codegen_typed'; +import {emit as untypedEmit} from './output_emitter_codegen_untyped'; + +// Usage: +// node path/to/output_emitter_codegen [typed output file] [untyped output file] +function main(argv: string[]) { + const [typed, untyped] = argv; + writeFileSync(typed, typedEmit()); + writeFileSync(untyped, untypedEmit()); +} + +if (require.main === module) { + main(process.argv.slice(2)); +} diff --git a/modules/@angular/compiler/test/output/output_emitter_codegen_typed.ts b/modules/@angular/compiler/test/output/output_emitter_codegen_typed.ts index d1e76a677a..e54cbae412 100644 --- a/modules/@angular/compiler/test/output/output_emitter_codegen_typed.ts +++ b/modules/@angular/compiler/test/output/output_emitter_codegen_typed.ts @@ -13,16 +13,8 @@ import {TypeScriptEmitter} from '@angular/compiler/src/output/ts_emitter'; import {print} from '@angular/facade/src/lang'; import {assetUrl} from '@angular/compiler/src/util'; -function unimplemented(): any { - throw new Error('unimplemented'); -} - import {SimpleJsImportGenerator, codegenExportsVars, codegenStmts} from './output_emitter_util'; -export function getExpressions(): any { - return unimplemented(); -} - // Generator export function emit() { const emitter = new TypeScriptEmitter(new SimpleJsImportGenerator()); diff --git a/modules/@angular/compiler/test/output/output_emitter_codegen_untyped.ts b/modules/@angular/compiler/test/output/output_emitter_codegen_untyped.ts index 5b777bd747..39503ac5a1 100644 --- a/modules/@angular/compiler/test/output/output_emitter_codegen_untyped.ts +++ b/modules/@angular/compiler/test/output/output_emitter_codegen_untyped.ts @@ -14,10 +14,6 @@ import {assetUrl} from '@angular/compiler/src/util'; import {SimpleJsImportGenerator, codegenExportsVars, codegenStmts} from './output_emitter_util'; -export function getExpressions(): any { - throw new Error('unimplemented'); -} - // Generator export function emit() { var emitter = new JavaScriptEmitter(new SimpleJsImportGenerator()); diff --git a/modules/@angular/compiler/test/output/output_emitter_generated_typed.d.ts b/modules/@angular/compiler/test/output/output_emitter_generated_typed.d.ts new file mode 100644 index 0000000000..e801dc2cf1 --- /dev/null +++ b/modules/@angular/compiler/test/output/output_emitter_generated_typed.d.ts @@ -0,0 +1,9 @@ +/** + * @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 + */ + +export function getExpressions(): any; diff --git a/modules/@angular/compiler/test/output/output_emitter_generated_untyped.d.ts b/modules/@angular/compiler/test/output/output_emitter_generated_untyped.d.ts new file mode 100644 index 0000000000..e801dc2cf1 --- /dev/null +++ b/modules/@angular/compiler/test/output/output_emitter_generated_untyped.d.ts @@ -0,0 +1,9 @@ +/** + * @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 + */ + +export function getExpressions(): any; diff --git a/modules/@angular/compiler/test/output/output_emitter_spec.ts b/modules/@angular/compiler/test/output/output_emitter_spec.ts index 76a13cb082..9673944b33 100644 --- a/modules/@angular/compiler/test/output/output_emitter_spec.ts +++ b/modules/@angular/compiler/test/output/output_emitter_spec.ts @@ -15,8 +15,8 @@ import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter'; import {browserDetection} from '@angular/platform-browser/testing/browser_util'; import {expect} from '@angular/platform-browser/testing/matchers'; -import * as typed from './output_emitter_codegen_typed'; -import * as untyped from './output_emitter_codegen_untyped'; +import * as typed from './output_emitter_generated_typed'; +import * as untyped from './output_emitter_generated_untyped'; import {ExternalClass, codegenStmts} from './output_emitter_util'; export function main() {