Skip to content

Commit

Permalink
upgrade chalk and webpack
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnyreilly committed Oct 19, 2017
1 parent 8bad811 commit 239bf5a
Show file tree
Hide file tree
Showing 12 changed files with 90 additions and 231 deletions.
1 change: 0 additions & 1 deletion package.json
Expand Up @@ -42,7 +42,6 @@
"semver": "^5.0.1"
},
"devDependencies": {
"@types/chalk": "^0.4.31",
"@types/semver": "^5.4.0",
"babel": "^6.0.0",
"babel-core": "^6.0.0",
Expand Down
6 changes: 3 additions & 3 deletions src/instances.ts
@@ -1,7 +1,7 @@
import * as typescript from 'typescript';
import * as path from 'path';
import * as fs from 'fs';
import { constructor as ChalkConstructor, Chalk } from 'chalk';
import chalk from 'chalk';

import { makeAfterCompile } from './after-compile';
import { getConfigFile, getConfigParseResult } from './config';
Expand Down Expand Up @@ -37,7 +37,7 @@ export function getTypeScriptInstance(
return { instance: instances[loaderOptions.instance] };
}

const colors = new ChalkConstructor({ enabled: loaderOptions.colors });
const colors = new chalk.constructor({ enabled: loaderOptions.colors });
const log = logger.makeLogger(loaderOptions, colors);
const compiler = getCompiler(loaderOptions, log);

Expand All @@ -55,7 +55,7 @@ function successfulTypeScriptInstance(
loaderOptions: LoaderOptions,
loader: Webpack,
log: logger.Logger,
colors: Chalk,
colors: typeof chalk,
compiler: typeof typescript,
compilerCompatible: boolean,
compilerDetailsLogMessage: string
Expand Down
10 changes: 5 additions & 5 deletions src/logger.ts
@@ -1,6 +1,6 @@
import { Console } from 'console';
import { LoaderOptions } from './interfaces';
import { Chalk, ChalkChain } from 'chalk';
import chalk from 'chalk';

type InternalLoggerFunc = (whereToLog: any, message: string) => void;

Expand Down Expand Up @@ -33,23 +33,23 @@ const makeExternalLogger = (loaderOptions: LoaderOptions, logger: InternalLogger
(message: string) =>
logger(loaderOptions.logInfoToStdOut ? stdoutConsole : stderrConsole, message);

const makeLogInfo = (loaderOptions: LoaderOptions, logger: InternalLoggerFunc, green: ChalkChain) =>
const makeLogInfo = (loaderOptions: LoaderOptions, logger: InternalLoggerFunc, green: typeof chalk) =>
LogLevel[loaderOptions.logLevel] <= LogLevel.INFO
? (message: string) =>
logger(loaderOptions.logInfoToStdOut ? stdoutConsole : stderrConsole, green(message))
: doNothingLogger;

const makeLogError = (loaderOptions: LoaderOptions, logger: InternalLoggerFunc, red: ChalkChain) =>
const makeLogError = (loaderOptions: LoaderOptions, logger: InternalLoggerFunc, red: typeof chalk) =>
LogLevel[loaderOptions.logLevel] <= LogLevel.ERROR
? (message: string) => logger(stderrConsole, red(message))
: doNothingLogger;

const makeLogWarning = (loaderOptions: LoaderOptions, logger: InternalLoggerFunc, yellow: ChalkChain) =>
const makeLogWarning = (loaderOptions: LoaderOptions, logger: InternalLoggerFunc, yellow: typeof chalk) =>
LogLevel[loaderOptions.logLevel] <= LogLevel.WARN
? (message: string) => logger(stderrConsole, yellow(message))
: doNothingLogger;

export function makeLogger(loaderOptions: LoaderOptions, colors: Chalk): Logger {
export function makeLogger(loaderOptions: LoaderOptions, colors: typeof chalk): Logger {
const logger = makeLoggerFunc(loaderOptions);
return {
log: makeExternalLogger(loaderOptions, logger),
Expand Down
2 changes: 1 addition & 1 deletion test/comparison-tests/colors/expectedOutput-2.5/bundle.js
Expand Up @@ -67,7 +67,7 @@
/* 0 */
/***/ (function(module, exports) {

throw new Error("Module parse failed: C:/source/ts-loader/index.js??ref--0!/colors/app.ts Unexpected token (1:9)\nYou may need an appropriate loader to handle this file type.\n| var a = == 0;\n| ");
throw new Error("Module parse failed: Unexpected token (1:9)\nYou may need an appropriate loader to handle this file type.\n| var a = == 0;\n| ");

/***/ })
/******/ ]);

This file was deleted.

@@ -1,9 +1,9 @@
Asset Size Chunks Chunk Names
bundle.js 2.71 kB 0 [emitted] main
[0] ./.test/colors/app.ts 242 bytes {0} [built] [failed] [2 errors]
bundle.js 2.62 kB 0 [emitted] main
[0] ./.test/colors/app.ts 147 bytes {0} [built] [failed] [2 errors]

ERROR in ./.test/colors/app.ts
Module parse failed: index.js??ref--0!app.ts Unexpected token (1:9)
Module parse failed: Unexpected token (1:9)
You may need an appropriate loader to handle this file type.
| var a = == 0;
|
Expand Down
6 changes: 3 additions & 3 deletions test/comparison-tests/colors/expectedOutput-2.5/output.txt
@@ -1,13 +1,13 @@
Asset Size Chunks Chunk Names
bundle.js 2.71 kB 0 [emitted] main
[0] ./.test/colors/app.ts 232 bytes {0} [built] [failed] [2 errors]
bundle.js 2.62 kB 0 [emitted] main
[0] ./.test/colors/app.ts 147 bytes {0} [built] [failed] [2 errors]

ERROR in ./.test/colors/app.ts
[tsl] ERROR in app.ts(1,7)
TS1005: '=' expected.

ERROR in ./.test/colors/app.ts
Module parse failed: index.js??ref--0!app.ts Unexpected token (1:9)
Module parse failed: Unexpected token (1:9)
You may need an appropriate loader to handle this file type.
| var a = == 0;
|
2 changes: 1 addition & 1 deletion test/comparison-tests/errors/expectedOutput-2.5/bundle.js
Expand Up @@ -67,7 +67,7 @@
/* 0 */
/***/ (function(module, exports) {

throw new Error("Module parse failed: C:/source/ts-loader/index.js??ref--0!/errors/app.ts Unexpected token (1:9)\nYou may need an appropriate loader to handle this file type.\n| var a = == 0;\n| ");
throw new Error("Module parse failed: Unexpected token (1:9)\nYou may need an appropriate loader to handle this file type.\n| var a = == 0;\n| ");

/***/ })
/******/ ]);

This file was deleted.

This file was deleted.

6 changes: 3 additions & 3 deletions test/comparison-tests/errors/expectedOutput-2.5/output.txt
@@ -1,13 +1,13 @@
Asset Size Chunks Chunk Names
bundle.js 2.71 kB 0 [emitted] main
[0] ./.test/errors/app.ts 232 bytes {0} [built] [failed] [2 errors]
bundle.js 2.62 kB 0 [emitted] main
[0] ./.test/errors/app.ts 147 bytes {0} [built] [failed] [2 errors]

ERROR in ./.test/errors/app.ts
[tsl] ERROR in app.ts(1,7)
 TS1005: '=' expected.

ERROR in ./.test/errors/app.ts
Module parse failed: index.js??ref--0!app.ts Unexpected token (1:9)
Module parse failed: Unexpected token (1:9)
You may need an appropriate loader to handle this file type.
| var a = == 0;
|

0 comments on commit 239bf5a

Please sign in to comment.