Skip to content

Commit

Permalink
fix: circumvent moduleExists() Vite bug
Browse files Browse the repository at this point in the history
  • Loading branch information
brillout committed Feb 8, 2022
1 parent dad5498 commit 32da7fd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions telefunc/node/vite/loadTelefuncFilesWithVite.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assert, hasProp, isObject, moduleExists } from '../utils'
import { assert, hasProp, isObject } from '../utils'
import type { ViteDevServer } from 'vite'
import { loadViteEntry } from './loadViteEntry'
import { TelefuncFiles } from '../server/types'
Expand All @@ -13,7 +13,8 @@ async function loadTelefuncFilesWithVite(runContext: {
isProduction: boolean
}): Promise<TelefuncFiles> {
const viteEntryFile = 'importTelefuncFiles.js'
assert(moduleExists(`./${viteEntryFile}`, __dirname))
// Vite occasionally chokes upon `moduleExists()` in dev
// assert(moduleExists(`./${viteEntryFile}`, __dirname))

const userDist = `${runContext.root}/dist`
const prodPath = `${userDist}/server/${viteEntryFile}`
Expand Down
3 changes: 2 additions & 1 deletion telefunc/node/vite/loadViteEntry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ async function loadViteEntry({
} else {
assert(viteDevServer)
devPath = nodeRequire.resolve(devPath)
assert(moduleExists(devPath))
// Vite occasionally chokes upon `moduleExists()` in dev
// assert(moduleExists(devPath))
try {
moduleExports = await viteDevServer.ssrLoadModule(devPath)
} catch (err: unknown) {
Expand Down

0 comments on commit 32da7fd

Please sign in to comment.