Skip to content

Commit

Permalink
fix: throw error on build optimizeDeps issue (#12560)
Browse files Browse the repository at this point in the history
  • Loading branch information
patak-dev committed Mar 24, 2023
1 parent a326ec8 commit 02a46d7
Showing 1 changed file with 6 additions and 18 deletions.
24 changes: 6 additions & 18 deletions packages/vite/src/node/plugins/optimizedDeps.ts
Expand Up @@ -116,31 +116,19 @@ export function optimizedDepsBuildPlugin(config: ResolvedConfig): Plugin {
// If all the inputs are dependencies, we aren't going to get any
const info = optimizedDepInfoFromFile(depsOptimizer.metadata, file)
if (info) {
try {
// This is an entry point, it may still not be bundled
await info.processing
} catch {
// If the refresh has not happened after timeout, Vite considers
// something unexpected has happened. In this case, Vite
// returns an empty response that will error.
// throwProcessingError(id)
return
}
await info.processing
isDebug && debug(`load ${colors.cyan(file)}`)
} else {
// TODO: error
return
throw new Error(
`Something unexpected happened while optimizing "${id}".`,
)
}

// Load the file from the cache instead of waiting for other plugin
// load hooks to avoid race conditions, once processing is resolved,
// we are sure that the file has been properly save to disk
try {
return await fs.readFile(file, 'utf-8')
} catch (e) {
// Outdated non-entry points (CHUNK), loaded after a rerun
return ''
}

return await fs.readFile(file, 'utf-8')
},
}
}
Expand Down

0 comments on commit 02a46d7

Please sign in to comment.