Skip to content

Commit

Permalink
fix: add named export to improve "module": "nodenext" compatibility (
Browse files Browse the repository at this point in the history
…#140)

* add named export to improve `"module": "nodenext"` compatibility

* currently it shows error:
This expression is not callable.
  Type 'typeof import("node_modules/vite-plugin-checker/lib/main")' has no call signatures.ts(2349)
* see microsoft/TypeScript#48845

* switch to cjs module style

* Revert "switch to cjs module style"

This reverts commit ef7a774.

* remove extra semicolon

* fix patch
  • Loading branch information
wight554 authored Jul 23, 2022
1 parent 3e6fa02 commit dca4157
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion packages/vite-plugin-checker/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function createCheckers(userConfig: UserPluginConfig, env: ConfigEnv): ServeAndB
return serveAndBuildCheckers
}

export default function Plugin(userConfig: UserPluginConfig): Plugin {
export function checker(userConfig: UserPluginConfig): Plugin {
const enableBuild = userConfig?.enableBuild ?? true
const enableOverlay = userConfig?.overlay !== false
const enableTerminal = userConfig?.terminal !== false
Expand Down Expand Up @@ -259,3 +259,5 @@ function spawnChecker(
export function isObject(value: unknown): value is Record<string, any> {
return Object.prototype.toString.call(value) === '[object Object]'
}

export default checker
2 changes: 1 addition & 1 deletion packages/vite-plugin-checker/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function createPatchEsbuildDistPlugin(): Plugin {
process.exit(1)
}

const modifiedCode = patchEsbuildDist(targetFile.text, 'Plugin')
const modifiedCode = patchEsbuildDist(targetFile.text, 'checker')

if (modifiedCode) {
Object.defineProperty(targetFile, 'text', { value: modifiedCode })
Expand Down

0 comments on commit dca4157

Please sign in to comment.