From e50d5cd7fc971fdbde58d425b3779abe637a63ff Mon Sep 17 00:00:00 2001 From: John Reilly Date: Tue, 24 Oct 2017 16:21:15 +0100 Subject: [PATCH] Fix chalk 2.3 incompatibility --- CHANGELOG.md | 4 ++++ package.json | 4 ++-- src/instances.ts | 4 ++-- src/logger.ts | 10 +++++----- yarn.lock | 8 ++++++++ 5 files changed, 21 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a68d72f96..51b214440 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v3.0.6 + +- [Chore release; upgraded chalk dependency in `package.json` to 2.3, as 2.3 is another breaking changes release (from a TypeScript perspective).](https://github.com/TypeStrong/ts-loader/issues/664), see [here](https://github.com/chalk/chalk/issues/215) for context - thanks @johnnyreilly + ## v3.0.5 - [Chore release; upgraded chalk dependency in `package.json` to 2.2, as 2.2 appears to be a breaking changes release.](https://github.com/TypeStrong/ts-loader/issues/664) - thanks @lmk123 for reporting diff --git a/package.json b/package.json index 2d6921166..509263b96 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ts-loader", - "version": "3.0.5", + "version": "3.0.6", "description": "TypeScript loader for webpack", "main": "index.js", "scripts": { @@ -36,7 +36,7 @@ }, "homepage": "https://github.com/TypeStrong/ts-loader", "dependencies": { - "chalk": "^2.2.0", + "chalk": "^2.3.0", "enhanced-resolve": "^3.0.0", "loader-utils": "^1.0.2", "semver": "^5.0.1" diff --git a/src/instances.ts b/src/instances.ts index 8dcf30d5c..9135b280b 100644 --- a/src/instances.ts +++ b/src/instances.ts @@ -1,7 +1,7 @@ import * as typescript from 'typescript'; import * as path from 'path'; import * as fs from 'fs'; -import chalk from 'chalk'; +import chalk, { Chalk } from 'chalk'; import { makeAfterCompile } from './after-compile'; import { getConfigFile, getConfigParseResult } from './config'; @@ -55,7 +55,7 @@ function successfulTypeScriptInstance( loaderOptions: LoaderOptions, loader: Webpack, log: logger.Logger, - colors: typeof chalk, + colors: Chalk, compiler: typeof typescript, compilerCompatible: boolean, compilerDetailsLogMessage: string diff --git a/src/logger.ts b/src/logger.ts index c7313dbaf..0d9b19dac 100644 --- a/src/logger.ts +++ b/src/logger.ts @@ -1,6 +1,6 @@ import { Console } from 'console'; import { LoaderOptions } from './interfaces'; -import chalk from 'chalk'; +import { Chalk } from 'chalk'; type InternalLoggerFunc = (whereToLog: any, message: string) => void; @@ -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: typeof chalk) => +const makeLogInfo = (loaderOptions: LoaderOptions, logger: InternalLoggerFunc, green: Chalk) => LogLevel[loaderOptions.logLevel] <= LogLevel.INFO ? (message: string) => logger(loaderOptions.logInfoToStdOut ? stdoutConsole : stderrConsole, green(message)) : doNothingLogger; -const makeLogError = (loaderOptions: LoaderOptions, logger: InternalLoggerFunc, red: typeof chalk) => +const makeLogError = (loaderOptions: LoaderOptions, logger: InternalLoggerFunc, red: Chalk) => LogLevel[loaderOptions.logLevel] <= LogLevel.ERROR ? (message: string) => logger(stderrConsole, red(message)) : doNothingLogger; -const makeLogWarning = (loaderOptions: LoaderOptions, logger: InternalLoggerFunc, yellow: typeof chalk) => +const makeLogWarning = (loaderOptions: LoaderOptions, logger: InternalLoggerFunc, yellow: Chalk) => LogLevel[loaderOptions.logLevel] <= LogLevel.WARN ? (message: string) => logger(stderrConsole, yellow(message)) : doNothingLogger; -export function makeLogger(loaderOptions: LoaderOptions, colors: typeof chalk): Logger { +export function makeLogger(loaderOptions: LoaderOptions, colors: Chalk): Logger { const logger = makeLoggerFunc(loaderOptions); return { log: makeExternalLogger(loaderOptions, logger), diff --git a/yarn.lock b/yarn.lock index 6ead3f826..f1f5cf162 100644 --- a/yarn.lock +++ b/yarn.lock @@ -978,6 +978,14 @@ chalk@^2.0.1, chalk@^2.1.0: escape-string-regexp "^1.0.5" supports-color "^4.0.0" +chalk@^2.3.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.3.0.tgz#b5ea48efc9c1793dccc9b4767c93914d3f2d52ba" + dependencies: + ansi-styles "^3.1.0" + escape-string-regexp "^1.0.5" + supports-color "^4.0.0" + chokidar@^1.4.1, chokidar@^1.7.0: version "1.7.0" resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-1.7.0.tgz#798e689778151c8076b4b360e5edd28cda2bb468"