Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(typescript-build): set logger instance correctly #580

Merged
merged 4 commits into from
Mar 20, 2023
Merged
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
20 changes: 15 additions & 5 deletions packages/typescript-build/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import path from 'path'
import { defu } from 'defu'
import consola from 'consola'
import { Module } from '@nuxt/types'
import { Options as TsLoaderOptions } from 'ts-loader'
import { ForkTsCheckerWebpackPluginOptions as TsCheckerOptions } from 'fork-ts-checker-webpack-plugin/lib/ForkTsCheckerWebpackPluginOptions'
import { RuleSetUseItem } from 'webpack'
import type { Module } from '@nuxt/types'
import type { Options as TsLoaderOptions } from 'ts-loader'
import type { ForkTsCheckerWebpackPluginOptions as TsCheckerOptions } from 'fork-ts-checker-webpack-plugin/lib/ForkTsCheckerWebpackPluginOptions'
import type TsCheckerLogger from 'fork-ts-checker-webpack-plugin/lib/logger/Logger'
import type { RuleSetUseItem } from 'webpack'

export interface Options {
ignoreNotFoundWarnings?: boolean
Expand Down Expand Up @@ -72,14 +73,23 @@ const tsModule: Module<Options> = function (moduleOptions) {
if (options.typeCheck && isClient && !isModern) {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin')
const logger = consola.withTag('nuxt:typescript')
/* istanbul ignore next */
const loggerInterface: TsCheckerLogger = {
log (message) { logger.log(message) },
info (message) { logger.info(message) },
error (message) { logger.error(message) }
}
config.plugins!.push(new ForkTsCheckerWebpackPlugin(defu(options.typeCheck, {
typescript: {
configFile: path.resolve(this.options.rootDir!, 'tsconfig.json'),
extensions: {
vue: true
}
},
logger: consola.withScope('nuxt:typescript')
logger: {
issues: loggerInterface
}
} as TsCheckerOptions)))
}
})
Expand Down