-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
142 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,70 @@ | ||
import { CreateDiagnostic } from '../types' | ||
import { isMainThread, parentPort, Worker, workerData } from 'worker_threads' | ||
|
||
import type { CheckerFactory } from '../types' | ||
import { ACTION_TYPES } from '../types' | ||
|
||
import type { | ||
CheckerFactory, | ||
CheckWorker, | ||
ConfigAction, | ||
ConfigureServerAction, | ||
CreateDiagnostic, | ||
BuildCheckBin, | ||
} from '../types' | ||
import type { UserConfig, ViteDevServer } from 'vite' | ||
|
||
// TODO: watch mode is note supported | ||
/** | ||
* Prints a diagnostic every time the watch status changes. | ||
* This is mainly for messages like "Starting compilation" or "Compilation completed". | ||
* | ||
*/ | ||
// @ts-ignore | ||
export const createDiagnostic: CreateDiagnostic = (userOptions = {}) => { | ||
return { | ||
config: (config: UserConfig) => { | ||
// TODO: watch mode is note supported | ||
// | ||
}, | ||
configureServer(server: ViteDevServer) { | ||
// TODO: watch mode is note supported | ||
// | ||
}, | ||
} | ||
} | ||
|
||
export const buildBin: BuildCheckBin = ['vue-tsc', ['--noEmit']] | ||
|
||
export const checkerFactory: CheckerFactory = () => { | ||
return { | ||
buildBin: ['vue-tsc', ['--noEmit']], | ||
createDiagnostic: createDiagnostic, | ||
} | ||
} | ||
|
||
export type VueTscCheckerOptions = Record<string, never> | ||
// TODO: watch mode is note supported | ||
// Nothing will happened, just satisfy type check | ||
if (isMainThread) { | ||
// initialized in main thread | ||
const createWorker = (userConfigs?: Record<string, never>): CheckWorker => { | ||
const worker = new Worker(__filename, { | ||
workerData: userConfigs, | ||
}) | ||
|
||
return { | ||
worker, | ||
config: (config) => { | ||
const configAction: ConfigAction = { type: ACTION_TYPES.config, payload: config } | ||
worker.postMessage(configAction) | ||
}, | ||
configureServer: (serverConfig) => { | ||
const configureServerAction: ConfigureServerAction = { | ||
type: ACTION_TYPES.configureServer, | ||
payload: serverConfig, | ||
} | ||
worker.postMessage(configureServerAction) | ||
}, | ||
} | ||
} | ||
|
||
module.exports.createWorker = createWorker | ||
} else { | ||
// | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters