New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

typescript-require

Package Overview
Dependencies
Maintainers
1
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.0 to 0.2.1

55

index.js

@@ -7,4 +7,13 @@ var os = require('os');

var tsc = require.resolve("typescript").replace(/typescript\.js$/, "tsc.js");
var tscScript = vm.createScript('(function() { ' + fs.readFileSync(tsc, "utf8") + '})();', tsc);
var tscScript = vm.createScript(fs.readFileSync(tsc, "utf8"), tsc);
var options = {
nodeLib: false,
targetES5: true
};
module.exports = function(opts) {
options = merge(options, opts);
};
require.extensions['.ts'] = function(module) {

@@ -14,15 +23,17 @@ var exitCode = 0;

var argv = [
"node",
"tsc.js",
"--nolib",
"--target",
options.targetES5 ? "ES5" : "ES3",
"--out",
tmpDir,
path.resolve(__dirname, "typings/lib.d.ts"),
options.nodeLib ? path.resolve(__dirname, "typings/node.d.ts") : null,
module.filename
];
var proc = merge(merge({}, process), {
argv: [
"node",
"tsc.js",
"--nolib",
"--target",
"ES5",
"--out",
tmpDir,
path.resolve(__dirname, "typings/lib.d.ts"),
path.resolve(__dirname, "typings/node.d.ts"),
module.filename
],
argv: compact(argv),
exit: function(code) {

@@ -49,8 +60,16 @@ exitCode = code;

function merge(a, b) {
if (a && b) {
for (var key in b) {
a[key] = b[key];
}
if (a && b) {
for (var key in b) {
a[key] = b[key];
}
return a;
}
return a;
};
function compact(arr) {
var narr = [];
arr.forEach(function (data) {
if (data) narr.push(data);
});
return narr;
}

@@ -9,3 +9,3 @@ {

},
"version": "0.2.0",
"version": "0.2.1",
"main": "./index.js",

@@ -12,0 +12,0 @@ "repository": {

@@ -39,2 +39,19 @@ TypeScript Require Extension

# Configuration
It is possible to configure the require extension upon initialization:
// Initialize
require('typescript-require')({
nodeLib: false,
targetES5: true
});
### nodeLib [boolean] (default: false)
If **true** `node.d.ts` definitions file is loaded before custom ts files. This is disabled by default and you should use
///<reference path='node.d.ts'/>
at the beginning of your ts modules.
### targetES5 [boolean] (default: true)
Target ES5 / ES3 output mode.
# Module Dependencies in TS files

@@ -48,3 +65,3 @@ You can load any other TypeScript or Javascript module from your typescripts. However, you should

///<reference path='node.d.ts'/>
// Load a JavaScript module with standard Node.JS require

@@ -51,0 +68,0 @@ var foomodule = require('./foomodule.js');

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

///<reference path='../typings/node.d.ts'/>
import tsmodule = module("tsmodule");

@@ -2,0 +3,0 @@ var jsmodule = require("./jsmodule.js");

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