From c90fb4538b727956fb61dc891f3374bb1304253e Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Thu, 17 Mar 2016 10:16:32 -0700 Subject: [PATCH 1/4] fix(blueprints): change outDir value to ../dist-manual and document why that it's used only for debugging --- addon/ng2/blueprints/ng2/files/src/tsconfig.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addon/ng2/blueprints/ng2/files/src/tsconfig.json b/addon/ng2/blueprints/ng2/files/src/tsconfig.json index 165ab9b6d60f..75a08409b25f 100644 --- a/addon/ng2/blueprints/ng2/files/src/tsconfig.json +++ b/addon/ng2/blueprints/ng2/files/src/tsconfig.json @@ -9,7 +9,8 @@ "moduleResolution": "node", "noEmitOnError": true, "noImplicitAny": false, - "outDir": "../dist/", + "//outDir": "this option is used only during manual invocation of tsc usually while debugging", + "outDir": "../dist-manual/", "rootDir": ".", "sourceMap": true, "sourceRoot": "/", From e30629c365e2c9692cfa90c4c90563be2fa81a6d Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Wed, 16 Mar 2016 23:01:50 -0700 Subject: [PATCH 2/4] fix(build): correctly compile source files against typings It looks like previously we were grabbing typings from outside of the tmp/ directory. If this ever worked, it worked only by accident. --- lib/broccoli/angular2-app.js | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/lib/broccoli/angular2-app.js b/lib/broccoli/angular2-app.js index 2cb6ba39a958..e8bcc7420712 100644 --- a/lib/broccoli/angular2-app.js +++ b/lib/broccoli/angular2-app.js @@ -18,7 +18,17 @@ function Angular2App(defaults, options, additionalPaths) { } Angular2App.prototype.toTree = function() { - var sourceTree = 'src'; + var sourceDir = 'src'; + + var sourceTree = new Funnel('src', { + destDir: 'src' + }); + + var typingsTree = new Funnel('typings', { + include: ['browser.d.ts', 'browser/**'], + destDir: 'typings' + }); + var vendorNpmFiles = [ 'systemjs/dist/system-polyfills.js', 'systemjs/dist/system.src.js', @@ -31,28 +41,34 @@ Angular2App.prototype.toTree = function() { 'angular2/bundles/upgrade.dev.js' ]; + + if (this.options && this.options.vendorNpmFiles) { vendorNpmFiles = vendorNpmFiles.concat(this.options.vendorNpmFiles); } var tsConfigCompilerOptions = JSON.parse(fs.readFileSync('src/tsconfig.json', 'utf-8')).compilerOptions; + tsConfigCompilerOptions.rootFilePaths = ['typings.d.ts'].concat(this.additionalPaths) .map(function(name) { - return path.join(process.cwd(), sourceTree, name) + return path.join(process.cwd(), sourceDir, name) }); - var tsTree = compileWithTypescript(sourceTree, tsConfigCompilerOptions); - var tsSrcTree = new Funnel(sourceTree, { + var srcAndTypingsTree = mergeTrees([sourceDir, typingsTree]); + + var tsTree = compileWithTypescript(srcAndTypingsTree, tsConfigCompilerOptions); + + var tsSrcTree = new Funnel(sourceDir, { include: ['**/*.ts'], allowEmpty: true }); - var jsTree = new Funnel(sourceTree, { + var jsTree = new Funnel(sourceDir, { include: ['**/*.js'], allowEmpty: true }); - var assetTree = new Funnel(sourceTree, { + var assetTree = new Funnel(sourceDir, { include: ['**/*.*'], exclude: ['**/*.ts', '**/*.js'], allowEmpty: true From 3bcacb6ce6e8c2fc1881ad7d839b84c9ebf3f739 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Thu, 17 Mar 2016 10:13:27 -0700 Subject: [PATCH 3/4] fix: read compilation roots from the tsconfig.json#files --- addon/ng2/blueprints/ng2/files/src/tsconfig.json | 7 ++++++- lib/broccoli/angular2-app.js | 12 +++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/addon/ng2/blueprints/ng2/files/src/tsconfig.json b/addon/ng2/blueprints/ng2/files/src/tsconfig.json index 75a08409b25f..28cc5a60e546 100644 --- a/addon/ng2/blueprints/ng2/files/src/tsconfig.json +++ b/addon/ng2/blueprints/ng2/files/src/tsconfig.json @@ -15,5 +15,10 @@ "sourceMap": true, "sourceRoot": "/", "target": "es5" - } + }, + + "files": [ + "app/main.ts", + "typings.d.ts" + ] } diff --git a/lib/broccoli/angular2-app.js b/lib/broccoli/angular2-app.js index e8bcc7420712..0912b666cbe5 100644 --- a/lib/broccoli/angular2-app.js +++ b/lib/broccoli/angular2-app.js @@ -47,13 +47,19 @@ Angular2App.prototype.toTree = function() { vendorNpmFiles = vendorNpmFiles.concat(this.options.vendorNpmFiles); } - var tsConfigCompilerOptions = JSON.parse(fs.readFileSync('src/tsconfig.json', 'utf-8')).compilerOptions; + var tsconfig = JSON.parse(fs.readFileSync('src/tsconfig.json', 'utf-8')); + var tsConfigCompilerOptions = tsconfig.compilerOptions; - tsConfigCompilerOptions.rootFilePaths = ['typings.d.ts'].concat(this.additionalPaths) - .map(function(name) { + + // TODO(i): why do we need these additional paths? remove? + tsConfigCompilerOptions.rootFilePaths = this.additionalPaths.map(function(name) { return path.join(process.cwd(), sourceDir, name) }); + // TODO(i): kill rootFilePaths in broccoli-typescript and use tsconfig.json#files instead + tsConfigCompilerOptions.rootFilePaths = tsConfigCompilerOptions.rootFilePaths.concat(tsconfig.files); + + var srcAndTypingsTree = mergeTrees([sourceDir, typingsTree]); var tsTree = compileWithTypescript(srcAndTypingsTree, tsConfigCompilerOptions); From 19774b989841200551bbc523eb0995b8ec5b158c Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Thu, 17 Mar 2016 14:28:56 -0700 Subject: [PATCH 4/4] fix(build): compile source files from within the src/ directory We need to preserve the paths to be the same during build as they are in source repo, so that editor and build pipeline are aligned. --- lib/broccoli/angular2-app.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/broccoli/angular2-app.js b/lib/broccoli/angular2-app.js index 0912b666cbe5..5968fc01785e 100644 --- a/lib/broccoli/angular2-app.js +++ b/lib/broccoli/angular2-app.js @@ -57,13 +57,23 @@ Angular2App.prototype.toTree = function() { }); // TODO(i): kill rootFilePaths in broccoli-typescript and use tsconfig.json#files instead - tsConfigCompilerOptions.rootFilePaths = tsConfigCompilerOptions.rootFilePaths.concat(tsconfig.files); + tsConfigCompilerOptions.rootFilePaths = tsConfigCompilerOptions.rootFilePaths. + concat(tsconfig.files.map(function(p) { + // TODO(i): this is a hack - for some reason we need to prefix all paths with srcDir because + // tsc's "rootDir" doesn't take effect when resolving "files" paths + return path.join(sourceDir, p); + })); - var srcAndTypingsTree = mergeTrees([sourceDir, typingsTree]); + var srcAndTypingsTree = mergeTrees([sourceTree, typingsTree]); var tsTree = compileWithTypescript(srcAndTypingsTree, tsConfigCompilerOptions); + tsTree = new Funnel(tsTree, { + srcDir: 'src', + exclude: ['*.d.ts', 'tsconfig.json'] + }); + var tsSrcTree = new Funnel(sourceDir, { include: ['**/*.ts'], allowEmpty: true