build(broccoli-typescript): add support for moduleResolution=node

Closes #4779
This commit is contained in:
Igor Minar 2015-10-15 21:27:58 -07:00
parent b09788993d
commit 2c98a0f771
1 changed files with 11 additions and 4 deletions

View File

@ -223,10 +223,17 @@ class CustomLanguageServiceHost implements ts.LanguageServiceHost {
* not worth the potential issues with stale cache records.
*/
getScriptSnapshot(tsFilePath: string): ts.IScriptSnapshot {
let absoluteTsFilePath =
(tsFilePath == this.defaultLibFilePath || path.isAbsolute(tsFilePath)) ?
tsFilePath :
path.join(this.treeInputPath, tsFilePath);
let absoluteTsFilePath;
if (tsFilePath == this.defaultLibFilePath || path.isAbsolute(tsFilePath)) {
absoluteTsFilePath = tsFilePath;
} else if (this.compilerOptions.moduleResolution === ts.ModuleResolutionKind.NodeJs &&
tsFilePath.match(/^node_modules/)) {
absoluteTsFilePath = path.resolve(tsFilePath);
} else {
absoluteTsFilePath = path.join(this.treeInputPath, tsFilePath);
}
if (!fs.existsSync(absoluteTsFilePath)) {
// TypeScript seems to request lots of bogus paths during import path lookup and resolution,