Skip to content

Commit

Permalink
Add a fallback logger
Browse files Browse the repository at this point in the history
Fixes fi3ework#238

It appears `config.logger` can be null or undefined,
despite the typescript types for Vite specifying
logger as required
  • Loading branch information
james-yeoman committed Feb 29, 2024
1 parent 0a2a2e0 commit 530784d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/vite-plugin-checker/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
type UserPluginConfig,
} from './types.js'
import type { ConfigEnv, Plugin, Logger } from 'vite'
import { createLogger } from 'vite'

const buildInCheckerKeys: BuildInCheckerNames[] = [
'typescript',
Expand Down Expand Up @@ -96,7 +97,11 @@ export function checker(userConfig: UserPluginConfig): Plugin {
})
},
configResolved(config) {
logger = config.logger
if (config.logger) {
logger = config.logger
} else {
logger = createLogger()
}
baseWithOrigin = config.server.origin ? config.server.origin + config.base : config.base
isProduction ||= config.isProduction || config.command === 'build'
buildWatch = !!config.build.watch
Expand Down

0 comments on commit 530784d

Please sign in to comment.