Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ Most TypeScript-related options should be set using a
file. There are a few loader-specific options you can set although in general
you should not need to.

##### silent *(boolean) (default='false')*
If true, no console.log messages will be emitted.

##### compiler *(string) (default='typescript')*

Allows use of TypeScript compilers other than the official one. Should be
Expand Down
13 changes: 10 additions & 3 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ interface Dependency {
}

interface Options {
silent: boolean;
instance: string;
compiler: string;
configFileName: string;
Expand Down Expand Up @@ -86,6 +87,12 @@ function findConfigFile(compiler: typeof typescript, searchPath: string, configF

function ensureTypeScriptInstance(options: Options, loader: any): TSInstance {

function log(...messages: string[]): void {
if (!options.silent) {
console.log.apply(console, messages);
}
}

var compiler = require(options.compiler);
var files = <TSFiles>{};

Expand All @@ -100,7 +107,7 @@ function ensureTypeScriptInstance(options: Options, loader: any): TSInstance {
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);
// TODO: when 1.5 stable comes out, this will never be undefined. Instead it will
// have an 'error' property
Expand Down Expand Up @@ -166,7 +173,7 @@ function ensureTypeScriptInstance(options: Options, loader: any): TSInstance {
getCompilationSettings: () => compilerOptions,
getDefaultLibFileName: options => libFileName,
getNewLine: () => { return os.EOL },
log: message => console.log(message)
log: log
};

var languageService = compiler.createLanguageService(servicesHost, compiler.createDocumentRegistry())
Expand Down Expand Up @@ -280,4 +287,4 @@ function loader(contents) {
callback(null, contents, sourceMap)
}

export = loader;
export = loader;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ts-loader",
"version": "0.4.4",
"version": "0.4.5",
"description": "TypeScript loader for webpack",
"main": "index.js",
"scripts": {
Expand Down