From b09788993d9f89b8749bfc616d33b55102d780dc Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Thu, 15 Oct 2015 16:29:24 -0700 Subject: [PATCH] build(broccoli): make broccoli-typescript consume tsconfig style option Previously it supported a weird mixture of tsconfig and internal options. --- tools/broccoli/broccoli-typescript.ts | 17 +++++++++++------ tools/broccoli/trees/browser_tree.ts | 11 +++++------ tools/broccoli/trees/node_tree.ts | 7 +++---- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/tools/broccoli/broccoli-typescript.ts b/tools/broccoli/broccoli-typescript.ts index 9370c571ba..ab4e92ee7c 100644 --- a/tools/broccoli/broccoli-typescript.ts +++ b/tools/broccoli/broccoli-typescript.ts @@ -1,5 +1,4 @@ /// -/// import fs = require('fs'); import fse = require('fs-extra'); @@ -38,12 +37,18 @@ class DiffingTSCompiler implements DiffingBroccoliPlugin { static excludeExtensions = ['.d.ts']; constructor(public inputPath: string, public cachePath: string, public options) { - this.tsOpts = Object.create(options); + if (options.rootFilePaths) { + this.rootFilePaths = options.rootFilePaths.splice(0); + delete options.rootFilePaths; + } else { + this.rootFilePaths = []; + } + + // in tsc 1.7.x this api was renamed to parseJsonConfigFileContent + // the conversion is a bit awkward, see https://github.com/Microsoft/TypeScript/issues/5276 + this.tsOpts = ts.parseConfigFile({compilerOptions: options, files: []}, null, null).options; this.tsOpts.outDir = this.cachePath; - this.tsOpts.target = (ts).ScriptTarget[options.target]; - this.tsOpts.module = (ts).ModuleKind[options.module]; - this.tsOpts.experimentalDecorators = true; - this.rootFilePaths = options.rootFilePaths ? options.rootFilePaths.splice(0) : []; + this.tsServiceHost = new CustomLanguageServiceHost(this.tsOpts, this.rootFilePaths, this.fileRegistry, this.inputPath); this.tsService = ts.createLanguageService(this.tsServiceHost, ts.createDocumentRegistry()); diff --git a/tools/broccoli/trees/browser_tree.ts b/tools/broccoli/trees/browser_tree.ts index 8a4cfc8b57..a5a1f2e5ff 100644 --- a/tools/broccoli/trees/browser_tree.ts +++ b/tools/broccoli/trees/browser_tree.ts @@ -112,34 +112,33 @@ module.exports = function makeBrowserTree(options, destinationPath) { // Use TypeScript to transpile the *.ts files to ES6 var es6Tree = compileWithTypescript(modulesTree, { - allowNonTsExtensions: false, declaration: false, emitDecoratorMetadata: true, + experimentalDecorators: true, mapRoot: '', // force sourcemaps to use relative path noEmitOnError: false, rootDir: '.', rootFilePaths: ['angular2/manual_typings/globals-es6.d.ts'], sourceMap: true, sourceRoot: '.', - target: 'ES6' + target: 'es6' }); // Use TypeScript to transpile the *.ts files to ES5 var typescriptOptions = { - allowNonTsExtensions: false, declaration: true, stripInternal: true, emitDecoratorMetadata: true, experimentalDecorators: true, mapRoot: '', // force sourcemaps to use relative path - module: 'CommonJS', - moduleResolution: 1 /* classic */, + module: 'commonjs', + moduleResolution: 'classic', noEmitOnError: true, rootDir: '.', rootFilePaths: ['angular2/manual_typings/globals.d.ts'], sourceMap: true, sourceRoot: '.', - target: 'ES5' + target: 'es5' }; var es5Tree = compileWithTypescript(es5ModulesTree, typescriptOptions); diff --git a/tools/broccoli/trees/node_tree.ts b/tools/broccoli/trees/node_tree.ts index d68f61e8ea..dab2506c1b 100644 --- a/tools/broccoli/trees/node_tree.ts +++ b/tools/broccoli/trees/node_tree.ts @@ -33,21 +33,20 @@ module.exports = function makeNodeTree(destinationPath) { }); var typescriptTree = compileWithTypescript(modulesTree, { - allowNonTsExtensions: false, emitDecoratorMetadata: true, experimentalDecorators: true, declaration: true, stripInternal: true, mapRoot: '', /* force sourcemaps to use relative path */ - module: 'CommonJS', - moduleResolution: 1 /* classic */, + module: 'commonjs', + moduleResolution: 'classic', noEmitOnError: true, rootDir: '.', rootFilePaths: ['angular2/manual_typings/globals.d.ts', 'angular2/typings/es6-shim/es6-shim.d.ts'], sourceMap: true, sourceRoot: '.', - target: 'ES5' + target: 'es5' }); // Now we add the LICENSE file into all the folders that will become npm packages