🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

meteor-typescript

Package Overview
Dependencies
Maintainers
1
Versions
103
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

meteor-typescript - npm Package Compare versions

Comparing version

to
0.8.3-beta1

15

compile-service.js

@@ -100,15 +100,14 @@ var assert = require("assert");

for (var usedPath in mappings) {
var module = mappings[usedPath];
mappings = mappings.filter(module => module.resolved && !module.external);
for (var module of mappings) {
var usedPath = module.modulePath;
var resolvedPath = module.resolvedPath;
if (module.external) continue;
// Fix some weird v2.1.x bug where
// LanguageService converts dotted paths
// to relative in the code.
var regExp = buildPathRegExp(resolvedPath);
code = code.replace(regExp, function(match, p1, p2, p3, offset) {
return p1 + tsu.getRootedPath(resolvedPath) + p3;
});
// var regExp = buildPathRegExp(resolvedPath);
// code = code.replace(regExp, function(match, p1, p2, p3, offset) {
// return p1 + tsu.getRootedPath(resolvedPath) + p3;
// });

@@ -115,0 +114,0 @@ // Skip path replacement for dotted paths.

@@ -0,1 +1,3 @@

'use strict';
var assert = require("assert");

@@ -100,30 +102,111 @@ var ts = require("typescript");

*/
function TSBuild(filePaths, getFileContent, options) {
Logger.debug("new build");
class TSBuild {
constructor(filePaths, getFileContent, options) {
Logger.debug("new build");
var arch = options && options.arch;
var compilerOptions = options && options.compilerOptions;
compilerOptions = defaultCompilerOptions(arch, compilerOptions);
var arch = options && options.arch;
var compilerOptions = options && options.compilerOptions;
compilerOptions = defaultCompilerOptions(arch, compilerOptions);
var resOptions = options || {};
resOptions.compilerOptions = compilerOptions;
var resOptions = options || {};
resOptions.compilerOptions = compilerOptions;
resOptions = validateAndConvertOptions(resOptions);
resOptions = validateAndConvertOptions(resOptions);
lazyInit();
lazyInit();
resOptions.compilerOptions = presetCompilerOptions(
resOptions.compilerOptions);
resOptions.compilerOptions = presetCompilerOptions(
resOptions.compilerOptions);
this.options = resOptions;
this.options = resOptions;
sourceHost.setSource(getFileContent);
sourceHost.setSource(getFileContent);
var pset = Logger.newProfiler("set files");
var compileService = getCompileService(resOptions.arch);
var serviceHost = compileService.getHost();
if (filePaths) {
serviceHost.setFiles(filePaths, resOptions);
var pset = Logger.newProfiler("set files");
var compileService = getCompileService(resOptions.arch);
var serviceHost = compileService.getHost();
if (filePaths) {
serviceHost.setFiles(filePaths, resOptions);
}
pset.end();
}
pset.end();
emit(filePath, moduleName) {
Logger.debug("emit file %s", filePath);
var options = this.options;
var compileService = getCompileService(options.arch);
var serviceHost = compileService.getHost();
if (! serviceHost.hasFile(filePath))
throw new Error("File " + filePath + " not found");
var useCache = options && options.useCache;
// Prepare file options which besides general ones
// should contain a module name. Omit arch to avoid
// re-compiling same files aimed for diff arch.
var noArchOpts = _.omit(options, 'arch', 'useCache');
var csOptions = {
options: noArchOpts,
moduleName: moduleName
};
function compile() {
var pcomp = Logger.newProfiler("compile " + filePath);
var result = compileService.compile(filePath, moduleName);
pcomp.end();
return result;
}
if (useCache === false) {
var result = compile();
compileCache.save(filePath, csOptions, result);
return result;
}
var pget = Logger.newProfiler("compileCache get");
var result = compileCache.get(filePath, csOptions, function(cacheResult) {
if (! cacheResult) {
Logger.debug("cache miss: %s", filePath);
return compile();
}
var csResult = createCSResult(cacheResult);
var tsDiag = csResult.diagnostics;
var prefs = Logger.newProfiler("refs check");
var refsChanged = isRefsChanged(serviceHost,
filePath, csResult.dependencies);
prefs.end();
// Referenced files have changed, which may need recompilation in some cases.
// See https://github.com/Urigo/angular2-meteor/issues/102#issuecomment-191411701
if (refsChanged === RefsType.FILES) {
Logger.debug("recompile: %s", filePath);
return compile();
}
// Diagnostics re-evaluation.
// First case: file is not changed but contains unresolved modules
// error from previous build (some node modules might have installed).
// Second case: dependency modules or typings have changed.
var unresolved = tsDiag.hasUnresolvedModules();
if (unresolved || refsChanged !== RefsType.NONE) {
Logger.debug("diagnostics re-evaluation: %s", filePath);
var pdiag = Logger.newProfiler("diags update");
csResult.upDiagnostics(
compileService.getDiagnostics(filePath));
pdiag.end();
return csResult;
}
// Cached result is up to date, no action required.
Logger.debug("file from cached: %s", filePath);
return null;
});
pget.end();
return result;
}
}

@@ -183,83 +266,2 @@

var BP = TSBuild.prototype;
BP.emit = function(filePath, moduleName) {
Logger.debug("emit file %s", filePath);
var options = this.options;
var compileService = getCompileService(options.arch);
var serviceHost = compileService.getHost();
if (! serviceHost.hasFile(filePath))
throw new Error("File " + filePath + " not found");
var useCache = options && options.useCache;
// Prepare file options which besides general ones
// should contain a module name. Omit arch to avoid
// re-compiling same files aimed for diff arch.
var noArchOpts = _.omit(options, 'arch', 'useCache');
var csOptions = {
options: noArchOpts,
moduleName: moduleName
};
function compile() {
var pcomp = Logger.newProfiler("compile " + filePath);
var result = compileService.compile(filePath, moduleName);
pcomp.end();
return result;
}
if (useCache === false) {
var result = compile();
compileCache.save(filePath, csOptions, result);
return result;
}
var pget = Logger.newProfiler("compileCache get");
var result = compileCache.get(filePath, csOptions, function(cacheResult) {
if (! cacheResult) {
Logger.debug("cache miss: %s", filePath);
return compile();
}
var csResult = createCSResult(cacheResult);
var tsDiag = csResult.diagnostics;
var prefs = Logger.newProfiler("refs check");
var refsChanged = isRefsChanged(serviceHost,
filePath, csResult.dependencies);
prefs.end();
// Referenced files have changed, which may need recompilation in some cases.
// See https://github.com/Urigo/angular2-meteor/issues/102#issuecomment-191411701
if (refsChanged === RefsType.FILES) {
Logger.debug("recompile: %s", filePath);
return compile();
}
// Diagnostics re-evaluation.
// First case: file is not changed but contains unresolved modules
// error from previous build (some node modules might have installed).
// Second case: dependency modules or typings have changed.
var unresolved = tsDiag.hasUnresolvedModules();
if (unresolved || refsChanged !== RefsType.NONE) {
Logger.debug("diagnostics re-evaluation: %s", filePath);
var pdiag = Logger.newProfiler("diags update");
csResult.upDiagnostics(
compileService.getDiagnostics(filePath));
pdiag.end();
return csResult;
}
// Cached result is up to date, no action required.
Logger.debug("file from cached: %s", filePath);
return null;
});
pget.end();
return result;
};
exports.compile = function compile(fileContent, options) {

@@ -266,0 +268,0 @@ if (typeof fileContent !== "string") {

{
"name": "meteor-typescript",
"author": "@barbatus",
"version": "0.8.2",
"version": "0.8.3-beta1",
"license": "MIT",

@@ -33,3 +33,3 @@ "description": "TypeScript wrapper package for use with Meteor",

"random-js": "^1.0.3",
"typescript": "2.1.5",
"typescript": "2.2.0",
"underscore": "^1.8.3"

@@ -36,0 +36,0 @@ },

@@ -111,14 +111,13 @@ var assert = require("assert");

function getMappings(sourceFile) {
var mappings = {};
var mappings = [];
if (sourceFile.resolvedModules) {
for (var modulePath in sourceFile.resolvedModules) {
var module = sourceFile.resolvedModules[modulePath];
if (module) {
mappings[modulePath] = {
resolvedPath: ts.removeFileExtension(
module.resolvedFileName),
external: module.isExternalLibraryImport
};
}
}
var modules = sourceFile.resolvedModules;
modules.forEach((module, modulePath) => {
mappings.push({
modulePath,
resolvedPath: module ? ts.removeFileExtension(module.resolvedFileName) : null,
external: module ? module.isExternalLibraryImport : false,
resolved: !!module
});
});
}

@@ -149,8 +148,8 @@ return mappings;

if (sourceFile.resolvedTypeReferenceDirectiveNames) {
for (var lib in sourceFile.resolvedTypeReferenceDirectiveNames) {
var ref = sourceFile.resolvedTypeReferenceDirectiveNames[lib];
if (ref) {
refTypings.push(ref.resolvedFileName);
}
}
var modules = sourceFile.resolvedTypeReferenceDirectiveNames;
modules.forEach((ref, lib) => {
if (! ref) return;
refTypings.push(ref.resolvedFileName);
});
}

@@ -157,0 +156,0 @@