broccoli-typify
Advanced tools
Comparing version 0.0.6 to 0.0.7
@@ -6,2 +6,3 @@ /// <reference path="../types/all.d.ts" /> | ||
var path = require('path'); | ||
var debug = require('debug'); | ||
var ts = require('typescript'); | ||
@@ -66,5 +67,12 @@ var diffing_broccoli_plugin_1 = require('./diffing-broccoli-plugin'); | ||
this.tsOpts.outDir = this.cachePath; | ||
if (this.rootFilePaths && this.rootFilePaths.length) { | ||
this._debug("CustomLanguageServiceHost rootFilePaths " + this.rootFilePaths.join(";")); | ||
} | ||
this._debug("CustomLanguageServiceHost inputPath " + this.inputPath); | ||
this.tsServiceHost = new CustomLanguageServiceHost(this.tsOpts, this.rootFilePaths, this.fileRegistry, this.inputPath); | ||
this.tsService = ts.createLanguageService(this.tsServiceHost, ts.createDocumentRegistry()); | ||
} | ||
DiffingTSCompiler.prototype._debug = function (message) { | ||
debug('broccoli-typify')("broccoli-typescript " + message); | ||
}; | ||
DiffingTSCompiler.prototype.rebuild = function (treeDiff) { | ||
@@ -255,4 +263,6 @@ var _this = this; | ||
// so we we just return undefined when the path is not correct. | ||
// Ensure it is in the input tree or a lib.d.ts file. | ||
if (!startsWith(tsFilePath, this.treeInputPath) && !tsFilePath.match(/\/lib(\..*)*.d\.ts$/)) { | ||
// Ensure it is in the input tree, an imported @type files or lib/*d.ts file. | ||
if (!startsWith(tsFilePath, this.treeInputPath) | ||
&& tsFilePath.indexOf('/node_modules/@types/') === -1 | ||
&& !tsFilePath.match(/\/lib(\..*)*.d\.ts$/)) { | ||
if (fs.existsSync(tsFilePath)) { | ||
@@ -275,2 +285,19 @@ console.log('Rejecting', tsFilePath, '. File is not in the input tree.'); | ||
}; | ||
CustomLanguageServiceHost.prototype.resolveModuleNames = function (moduleNames, containingFile) { | ||
var _this = this; | ||
return moduleNames.map(function (name) { | ||
if (name === 'ember') { | ||
return { | ||
resolvedFileName: _this.currentDirectory + "/node_modules/@types/ember/index.d.ts", | ||
isExternalLibraryImport: true | ||
}; | ||
} | ||
else { | ||
console.log("resolveModuleNames confused by '" + name + "'"); | ||
return { | ||
resolvedFileName: undefined | ||
}; | ||
} | ||
}); | ||
}; | ||
return CustomLanguageServiceHost; | ||
@@ -277,0 +304,0 @@ }()); |
{ | ||
"name": "broccoli-typify", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"description": "Provide broccoli building blocks for typescript pipelines.", | ||
@@ -42,2 +42,3 @@ "main": "dist/index.js", | ||
"@types/debug": "0.0.26-alpha", | ||
"@types/ember": "winding-lines/at-types-ember", | ||
"@types/fs-extra": "0.0.22-alpha", | ||
@@ -44,0 +45,0 @@ "@types/node": "^4.0.22-alpha", |
@@ -6,2 +6,3 @@ /// <reference path="../types/all.d.ts" /> | ||
import path = require('path'); | ||
import debug = require('debug'); | ||
import * as ts from 'typescript'; | ||
@@ -88,2 +89,6 @@ import {wrapDiffingPlugin, DiffingBroccoliPlugin, DiffResult} from './diffing-broccoli-plugin'; | ||
if (this.rootFilePaths && this.rootFilePaths.length) { | ||
this._debug("CustomLanguageServiceHost rootFilePaths " + this.rootFilePaths.join(";")); | ||
} | ||
this._debug("CustomLanguageServiceHost inputPath " + this.inputPath); | ||
this.tsServiceHost = new CustomLanguageServiceHost( | ||
@@ -94,3 +99,7 @@ this.tsOpts, this.rootFilePaths, this.fileRegistry, this.inputPath); | ||
private _debug(message) { | ||
debug('broccoli-typify')(`broccoli-typescript ${message}`) | ||
} | ||
rebuild(treeDiff: DiffResult) { | ||
@@ -300,4 +309,6 @@ let pathsToEmit: string[] = []; | ||
// Ensure it is in the input tree or a lib.d.ts file. | ||
if (!startsWith(tsFilePath, this.treeInputPath) && !tsFilePath.match(/\/lib(\..*)*.d\.ts$/)) { | ||
// Ensure it is in the input tree, an imported @type files or lib/*d.ts file. | ||
if (!startsWith(tsFilePath, this.treeInputPath) | ||
&& tsFilePath.indexOf('/node_modules/@types/') === -1 | ||
&& !tsFilePath.match(/\/lib(\..*)*.d\.ts$/)) { | ||
if (fs.existsSync(tsFilePath)) { | ||
@@ -326,2 +337,18 @@ console.log('Rejecting', tsFilePath, '. File is not in the input tree.'); | ||
} | ||
resolveModuleNames(moduleNames: string[], containingFile: string): ts.ResolvedModule[] { | ||
return moduleNames.map(name=>{ | ||
if (name === 'ember') { | ||
return { | ||
resolvedFileName: `${this.currentDirectory}/node_modules/@types/ember/index.d.ts`, | ||
isExternalLibraryImport: true | ||
} | ||
} else { | ||
console.log(`resolveModuleNames confused by '${name}'`); | ||
return <ts.ResolvedModule>{ | ||
resolvedFileName: undefined | ||
} | ||
} | ||
}); | ||
} | ||
} | ||
@@ -328,0 +355,0 @@ |
111109
2507
12