broccoli-typify
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -242,2 +242,8 @@ /// <reference path="../types/all.d.ts" /> | ||
}()); | ||
function fileExists(fileName) { | ||
return ts.sys.fileExists(fileName); | ||
} | ||
function readFile(fileName) { | ||
return ts.sys.readFile(fileName); | ||
} | ||
var CustomLanguageServiceHost = (function () { | ||
@@ -290,3 +296,9 @@ function CustomLanguageServiceHost(compilerOptions, fileNames, fileRegistry, treeInputPath) { | ||
return moduleNames.map(function (name) { | ||
// first try the default resolution | ||
var result = ts.resolveModuleName(name, containingFile, _this.compilerOptions, { fileExists: fileExists, readFile: readFile }); | ||
if (result.resolvedModule) { | ||
return result.resolvedModule; | ||
} | ||
if (name === 'ember') { | ||
// custom ember resolution while we stabilize the type definition | ||
var first = _this.currentDirectory + "/node_modules/at-types-ember/index.d.ts", second = _this.currentDirectory + "/node_modules/@types/ember/index.d.ts"; | ||
@@ -307,2 +319,3 @@ if (fs.existsSync(first)) { | ||
else if (name.indexOf('npm:') === 0) { | ||
// resolve npm: modules as loaded with ember-browserify | ||
var module_1 = name.split(':')[1], path_1 = _this.currentDirectory + "/node_modules/@types/" + module_1 + "/index.d.ts"; | ||
@@ -309,0 +322,0 @@ if (fs.existsSync(path_1)) { |
{ | ||
"name": "broccoli-typify", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Provide broccoli building blocks for typescript pipelines.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -280,3 +280,11 @@ /// <reference path="../types/all.d.ts" /> | ||
function fileExists(fileName: string): boolean { | ||
return ts.sys.fileExists(fileName); | ||
} | ||
function readFile(fileName: string): string { | ||
return ts.sys.readFile(fileName); | ||
} | ||
class CustomLanguageServiceHost implements ts.LanguageServiceHost { | ||
@@ -343,3 +351,10 @@ private currentDirectory: string; | ||
return moduleNames.map(name=>{ | ||
// first try the default resolution | ||
let result = ts.resolveModuleName(name, containingFile, this.compilerOptions, {fileExists, readFile}); | ||
if (result.resolvedModule) { | ||
return result.resolvedModule; | ||
} | ||
if (name === 'ember') { | ||
// custom ember resolution while we stabilize the type definition | ||
const first = `${this.currentDirectory}/node_modules/at-types-ember/index.d.ts`, | ||
@@ -360,2 +375,3 @@ second = `${this.currentDirectory}/node_modules/@types/ember/index.d.ts`; | ||
} else if (name.indexOf('npm:')===0) { | ||
// resolve npm: modules as loaded with ember-browserify | ||
const module = name.split(':')[1], path = `${this.currentDirectory}/node_modules/@types/${module}/index.d.ts`; | ||
@@ -362,0 +378,0 @@ if (fs.existsSync(path)) { |
116972
2653