-
Notifications
You must be signed in to change notification settings - Fork 12k
fix(build): correctly compile source files against typings #306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
c90fb45
e30629c
3bcacb6
19774b9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
}); | ||
|
||
var typingsTree = new Funnel('typings', { | ||
include: ['browser.d.ts', 'browser/**'], | ||
destDir: 'typings' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So this will end up in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no. it's available at tmp/XXX/typings during compilation but it doesn't make it into the final output. |
||
}); | ||
|
||
var vendorNpmFiles = [ | ||
'systemjs/dist/system-polyfills.js', | ||
'systemjs/dist/system.src.js', | ||
|
@@ -31,28 +41,50 @@ 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) | ||
var tsconfig = JSON.parse(fs.readFileSync('src/tsconfig.json', 'utf-8')); | ||
var tsConfigCompilerOptions = tsconfig.compilerOptions; | ||
|
||
|
||
// TODO(i): why do we need these additional paths? remove? | ||
tsConfigCompilerOptions.rootFilePaths = this.additionalPaths.map(function(name) { | ||
return path.join(process.cwd(), sourceDir, name) | ||
}); | ||
|
||
var tsTree = compileWithTypescript(sourceTree, tsConfigCompilerOptions); | ||
var tsSrcTree = new Funnel(sourceTree, { | ||
// TODO(i): kill rootFilePaths in broccoli-typescript and use tsconfig.json#files instead | ||
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([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 | ||
}); | ||
|
||
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 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please keep this as
../dist
as this is for tooling, more than command line usage oftsc
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in a follow up commit.