Skip to content

Commit

Permalink
fix: DataCloneError at worker.postMessage
Browse files Browse the repository at this point in the history
Only options that can be copied with "the structured clone algorithm" were explicitly specified.
  • Loading branch information
kazuma1989 authored and fi3ework committed Feb 6, 2022
1 parent 70dc07a commit e07269e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion packages/vite-plugin-checker/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,11 @@ export default function Plugin(userConfig: UserPluginConfig): Plugin {
checkers = createCheckers(userConfig || {}, env)
if (viteMode !== 'serve') return

const hmr = config.server?.hmr
checkers.forEach((checker) => {
const workerConfig = checker.serve.config
workerConfig({
hmr: config.server?.hmr,
hmr: typeof hmr === 'object' ? { overlay: hmr.overlay } : hmr,
env,
})
})
Expand Down
9 changes: 6 additions & 3 deletions packages/vite-plugin-checker/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { HMRPayload, ServerOptions, ConfigEnv } from 'vite'
import type { ConfigEnv, HMRPayload } from 'vite'
import type { Worker } from 'worker_threads'
import type { ESLint } from 'eslint'
import type { VlsOptions } from './checkers/vls/initParams'
Expand Down Expand Up @@ -125,7 +125,10 @@ export interface OverlayErrorAction extends Action {

export interface ConfigAction extends Action {
type: ACTION_TYPES.config
payload: Pick<ServerOptions, 'hmr'> & { env: ConfigEnv }
payload: {
hmr?: { overlay?: boolean } | boolean
env: ConfigEnv
}
}

export interface ConfigureServerAction extends Action {
Expand Down Expand Up @@ -169,7 +172,7 @@ export interface ServeChecker<T extends BuildInCheckerNames = any> {
}

export interface CheckerDiagnostic {
config: (options: Pick<ServerOptions, 'hmr'> & { env: ConfigEnv }) => unknown
config: (options: { hmr?: { overlay?: boolean } | boolean; env: ConfigEnv }) => unknown
configureServer: (options: { root: string }) => unknown
}

Expand Down

0 comments on commit e07269e

Please sign in to comment.