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

ts-loader

Package Overview
Dependencies
Maintainers
1
Versions
165
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-loader - npm Package Compare versions

Comparing version 0.4.4 to 0.4.5

4

CHANGELOG.md
# Changelog
## v0.4.5
- Add `silent` flag (#22)
## v0.4.4

@@ -4,0 +8,0 @@

@@ -15,5 +15,5 @@ ///<reference path="node_modules/typescript/bin/typescript.d.ts" />

var instances = {};
function consoleError(msg) {
setTimeout(function () { return console.log('ERROR' + os.EOL + msg); }, 0);
}
// Take TypeScript errors, parse them and "pretty-print" to a passed-in function
// The passed-in function can either console.log them or add them to webpack's
// list of errors
function handleErrors(diagnostics, compiler, outputFn) {

@@ -31,2 +31,4 @@ diagnostics.forEach(function (diagnostic) {

}
// The tsconfig.json is found using the same method as `tsc`, starting in the current directory
// and continuing up the parent directory chain.
function findConfigFile(compiler, searchPath, configFileName) {

@@ -46,3 +48,20 @@ while (true) {

}
// The loader is executed once for each file seen by webpack. However, we need to keep
// a persistent instance of TypeScript that contains all of the files in the program
// along with definition files and options. This function either creates an instance
// or returns the existing one. Multiple instances are possible by using the
// `instance` property.
function ensureTypeScriptInstance(options, loader) {
function log() {
var messages = [];
for (var _i = 0; _i < arguments.length; _i++) {
messages[_i - 0] = arguments[_i];
}
if (!options.silent) {
console.log.apply(console, messages);
}
}
function consoleError(msg) {
setTimeout(function () { return log('ERROR' + os.EOL + msg); }, 0);
}
var compiler = require(options.compiler);

@@ -56,6 +75,7 @@ var files = {};

};
// Load any available tsconfig.json file
var filesToLoad = [];
var configFilePath = findConfigFile(compiler, path.dirname(loader.resourcePath), options.configFileName);
if (configFilePath) {
console.log('Using config file at '.green + configFilePath.blue);
log('Using config file at '.green + configFilePath.blue);
var configFile = compiler.readConfigFile(configFilePath);

@@ -76,4 +96,4 @@ // TODO: when 1.5 stable comes out, this will never be undefined. Instead it will

var libFileName = 'lib.d.ts';
// Special handling for ES6 targets
if (compilerOptions.target == 2 /* ES6 */) {
// Special handling for ES6 targets
compilerOptions.module = 0 /* None */;

@@ -85,2 +105,3 @@ libFileName = 'lib.es6.d.ts';

}
// Load initial files (core lib files, any files specified in tsconfig.json)
filesToLoad.forEach(function (filePath) {

@@ -93,2 +114,3 @@ filePath = path.normalize(filePath);

});
// Create the TypeScript language service
var servicesHost = {

@@ -101,2 +123,4 @@ getScriptFileNames: function () { return Object.keys(files); },

getScriptSnapshot: function (fileName) {
// This is called any time TypeScript needs a file's text
// We either load from memory or from disk
fileName = path.normalize(fileName);

@@ -121,3 +145,3 @@ var file = files[fileName];

getNewLine: function () { return os.EOL; },
log: function (message) { return console.log(message); }
log: log
};

@@ -171,2 +195,3 @@ var languageService = compiler.createLanguageService(servicesHost, compiler.createDocumentRegistry());

options = objectAssign({}, {
silent: false,
instance: 'default',

@@ -177,2 +202,3 @@ compiler: 'typescript',

var instance = ensureTypeScriptInstance(options, this), file = instance.files[filePath], langService = instance.languageService;
// Update TypeScript with the new file contents
if (!file) {

@@ -183,5 +209,7 @@ file = instance.files[filePath] = { version: 0 };

file.version++;
// Make this file dependent on *all* definition files in the program
this.clearDependencies();
this.addDependency(filePath);
Object.keys(instance.files).filter(function (filePath) { return !!filePath.match(/\.d\.ts$/); }).forEach(this.addDependency.bind(this));
// Emit Javascript
var output = langService.getEmitOutput(filePath);

@@ -210,2 +238,5 @@ handleErrors(langService.getSyntacticDiagnostics(filePath).concat(langService.getSemanticDiagnostics(filePath)), instance.compiler, function (message, rawMessage, location) {

}
// Make sure webpack is aware that even though the emitted JavaScript may be the same as
// a previously cached version the TypeScript may be different and therefore should be
// treated as new
this._module.meta['tsLoaderFileVersion'] = file.version;

@@ -212,0 +243,0 @@ callback(null, contents, sourceMap);

2

package.json
{
"name": "ts-loader",
"version": "0.4.4",
"version": "0.4.5",
"description": "TypeScript loader for webpack",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -29,3 +29,3 @@ # TypeScript loader for webpack

resolve: {
extensions: ['', '.webpack.js', '.web.js', '.js', '.ts']
extensions: ['', '.webpack.js', '.web.js', '.ts', '.js']
},

@@ -47,2 +47,7 @@ module: {

##### silent *(boolean) (default=false)*
If true, no console.log messages will be emitted. Note that most error
messages are emitted via webpack which is not affected by this flag.
##### compiler *(string) (default='typescript')*

@@ -59,3 +64,3 @@

##### configFileName *(string) (default=tsconfig.json)*
##### configFileName *(string) (default='tsconfig.json')*

@@ -62,0 +67,0 @@ Allows you to specify a custom configuration file.

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