Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

typescript-require

Package Overview
Dependencies
Maintainers
4
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typescript-require - npm Package Compare versions

Comparing version 0.2.9 to 0.2.10

lib/index.js

27

index.js

@@ -7,3 +7,3 @@ var vm = require('vm');

var tscScript = vm.createScript(fs.readFileSync(tsc, "utf8"), tsc);
var libPath = path.join(path.dirname(require.resolve("typescript")), "lib.d.ts")
var libPath = path.join(path.dirname(require.resolve("typescript")), "lib.d.ts");

@@ -14,3 +14,5 @@ var options = {

moduleKind: 'commonjs',
exitOnError: true
emitOnError: false,
exitOnError: true,
tmpDir: path.join(process.cwd(), 'tmp')
};

@@ -29,7 +31,7 @@

var tsMTime = fs.statSync(tsname).mtime;
var jsMTime = 0;
try {
var jsMTime = fs.statSync(jsname).mtime;
jsMTime = fs.statSync(jsname).mtime;
} catch (e) { //catch if file does not exists
jsMTime = 0;
}

@@ -46,6 +48,6 @@

var exitCode = 0;
var tmpDir = path.join(process.cwd(), "tmp", "tsreq");
var tmpDir = path.join(options.tmpDir, "tsreq");
var relativeFolder = path.dirname(path.relative(process.cwd(), module.filename));
var jsname = path.join(tmpDir, relativeFolder, path.basename(module.filename, ".ts") + ".js");
if (!isModified(module.filename, jsname)) {

@@ -58,7 +60,10 @@ return jsname;

"tsc.js",
!! options.emitOnError ? "" : "--noEmitOnError",
"--nolib",
"--rootDir",
process.cwd(),
"--target",
options.targetES5 ? "ES5" : "ES3", !! options.moduleKind ? "--module" : "", !! options.moduleKind ? options.moduleKind : "",
"--outDir",
path.join(tmpDir, relativeFolder),
tmpDir,
libPath,

@@ -85,7 +90,9 @@ options.nodeLib ? path.resolve(__dirname, "typings/node.d.ts") : null,

Buffer: Buffer,
setTimeout: setTimeout
setTimeout: setTimeout,
clearTimeout: clearTimeout,
__filename: tsc
};
tscScript.runInNewContext(sandbox);
if (exitCode != 0) {
if (exitCode !== 0) {
throw new Error('Unable to compile TypeScript file.');

@@ -122,3 +129,3 @@ }

return a;
};
}

@@ -125,0 +132,0 @@ function compact(arr) {

{
"name": "typescript-require",
"description": "Node.JS require extension to load TypeScript modules from JS",
"homepage": "https://github.com/eknkc/typescript-require",
"homepage": "https://github.com/theblacksmith/typescript-require",
"author": {

@@ -20,10 +20,10 @@ "name": "Ekin Koc",

],
"version": "0.2.9",
"version": "0.2.10",
"main": "./index.js",
"repository": {
"type": "git",
"url": "git@github.com:eknkc/typescript-require.git"
"url": "git@github.com:theblacksmith/typescript-require.git"
},
"dependencies": {
"typescript": ">= 0.8.2"
"typescript": "^1.5.3"
},

@@ -30,0 +30,0 @@ "keywords": [

@@ -6,2 +6,4 @@ TypeScript Require Extension

[![Build Status](https://travis-ci.org/theblacksmith/typescript-require.svg)](https://travis-ci.org/theblacksmith/typescript-require)
# Install

@@ -47,3 +49,4 @@ Install via npm:

targetES5: true,
exitOnError: true
exitOnError: true,
emitOnError: true
});

@@ -61,2 +64,11 @@

### exitOnError [boolean] default: true
Calls `process.exit` if an error occurs during TypeScript compilation
### tmpDir [string] default: ./tmp
The directory underneath which output files should be placed
### emitOnError [boolean] default: false
Tells the TypeScript compiler whether or not to emit JS files if an error occurs.
# Module Dependencies in TS files

@@ -63,0 +75,0 @@ You can load any other TypeScript or Javascript module from your typescripts. However, you should

@@ -0,1 +1,2 @@

"use strict";
var Ship = (function () {

@@ -5,3 +6,3 @@ function Ship() {

return Ship;
})();
}());
exports.Ship = Ship;
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc