Skip to content

Commit

Permalink
Bump TypeScript to 1.5
Browse files Browse the repository at this point in the history
Minor refactoring
  • Loading branch information
barbatus committed Jan 25, 2017
1 parent 2a751a6 commit 650c181
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 26 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

TypeScript wrapped for Meteor.

Based on TypeScript@2.0.10.
Based on TypeScript@2.1.5.
12 changes: 6 additions & 6 deletions cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,25 +203,25 @@ exports.CompileCache = CompileCache;
* Used to check if a file content has been changed
* between two successive compilations.
*/
function FileCache(cacheDir) {
function FileHashCache(cacheDir) {
Cache.apply(this);
this.cacheDir = ensureCacheDir(cacheDir);
}

FileCache.prototype = new Cache();
FileHashCache.prototype = new Cache();

exports.FileCache = FileCache;
exports.FileHashCache = FileHashCache;

var FCp = FileCache.prototype = new Cache();
var FHCp = FileHashCache.prototype = new Cache();

FCp.save = function(filePath, arch, content) {
FHCp.save = function(filePath, arch, content) {
var profile = { filePath: filePath, arch: arch };
var cacheKey = utils.deepHash(profile);
var contentHash = utils.deepHash(content);
this._save(cacheKey, contentHash);
};

FCp.isChanged = function(filePath, arch, content) {
FHCp.isChanged = function(filePath, arch, content) {
var profile = { filePath: filePath, arch: arch };
var cacheKey = utils.deepHash(profile);
var contentHash = utils.deepHash(content);
Expand Down
8 changes: 8 additions & 0 deletions compile-service-host.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,18 @@ SH.setFiles = function(filePaths, options) {
this.options = options;
this.filePaths = filePaths;

var typings = [];
var arch = options && options.arch;
_.each(filePaths, function(filePath) {
if (! this.files[filePath]) {
this.files[filePath] = { version: 0 };
}

// Collect typings in order to set them later.
if (tsu.isTypings(filePath)) {
typings.push(filePath);
}

var source = sourceHost.get(filePath);
this.files[filePath].changed = false;
// Use file path with the current dir for the cache
Expand All @@ -42,6 +48,8 @@ SH.setFiles = function(filePaths, options) {
return;
}
}, this);

this.setTypings(typings, options);
};

SH.setTypings = function(typings, options) {
Expand Down
2 changes: 1 addition & 1 deletion compile-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ CP.rootifyPaths = function(code, mappings) {

if (module.external) continue;

// Fix some weird v2.1.1 bug where
// Fix some weird v2.1.x bug where
// LanguageService converts dotted paths
// to relative in the code.
var regExp = buildPathRegExp(resolvedPath);
Expand Down
17 changes: 4 additions & 13 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ var createCSResult = require("./compile-service").createCSResult;
var ServiceHost = require("./compile-service-host").CompileServiceHost;
var sourceHost = require("./files-source-host").sourceHost;
var CompileCache = require("./cache").CompileCache;
var FileCache = require("./cache").FileCache;
var FileHashCache = require("./cache").FileHashCache;
var Logger = require("./logger").Logger;
var deepHash = require("./utils").deepHash;
var utils = require("./utils");
var tsu = require("./ts-utils").ts;

var compileCache, fileCache;
var compileCache, fileHashCache;
function setCacheDir(cacheDir) {
if (compileCache && compileCache.cacheDir === cacheDir) {
return;
}

compileCache = new CompileCache(cacheDir);
fileCache = new FileCache(cacheDir);
fileHashCache = new FileHashCache(cacheDir);
};

exports.setCacheDir = setCacheDir;
Expand Down Expand Up @@ -75,7 +75,7 @@ function getCompileService(arch) {
if (! arch) arch = "global";
if (serviceMap[arch]) return serviceMap[arch];

var serviceHost = new ServiceHost(fileCache);
var serviceHost = new ServiceHost(fileHashCache);
var service = new CompileService(serviceHost);
serviceMap[arch] = service;
return service;
Expand Down Expand Up @@ -123,15 +123,6 @@ function TSBuild(filePaths, getFileContent, options) {
var serviceHost = compileService.getHost();
if (filePaths) {
serviceHost.setFiles(filePaths, resOptions);
var typings = [];
_.each(filePaths, function (filePath) {
// typings = typings.concat(
// compileService.getRefTypings(filePath));
if (tsu.isTypings(filePath)) {
typings.push(filePath);
}
});
serviceHost.setTypings(typings, resOptions);
}
pset.end();
}
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "meteor-typescript",
"author": "@barbatus",
"version": "0.8.1",
"version": "0.8.2",
"license": "MIT",
"description": "TypeScript wrapper package for use with Meteor",
"keywords": [
Expand Down Expand Up @@ -30,7 +30,7 @@
"lru-cache": "^2.6.4",
"object-sizeof": "^1.0.10",
"random-js": "^1.0.3",
"typescript": "2.1.4",
"typescript": "2.1.5",
"underscore": "^1.8.3"
},
"devDependencies": {
Expand Down
6 changes: 3 additions & 3 deletions ts-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ function getMappings(sourceFile) {
}

function getRefs(sourceFile) {
// Get references paths.
// Collect referenced file paths, e.g.:
// /// <reference path=".." />
var refTypings = [], refFiles = [];
if (sourceFile.referencedFiles) {
Expand All @@ -142,8 +142,8 @@ function getRefs(sourceFile) {
});
}

// Get resolved paths to reference types.
/// <reference types=".." />
// Collect resolved paths to referenced declaration types, e.g.:
// /// <reference types=".." />
if (sourceFile.resolvedTypeReferenceDirectiveNames) {
for (var lib in sourceFile.resolvedTypeReferenceDirectiveNames) {
var ref = sourceFile.resolvedTypeReferenceDirectiveNames[lib];
Expand Down

0 comments on commit 650c181

Please sign in to comment.