Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: nest deps chunk cannot be loaded when optimizing deps in build mode #13935

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 7 additions & 5 deletions packages/vite/src/node/plugins/optimizedDeps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,18 @@ export function optimizedDepsBuildPlugin(config: ResolvedConfig): Plugin {
if (info) {
await info.processing
debug?.(`load ${colors.cyan(file)}`)
} else {
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
return fsp.readFile(file, 'utf-8')
try {
return await fsp.readFile(file, 'utf-8')
} catch (e) {
throw new Error(
`Something unexpected happened while optimizing "${id}".`,
)
}
},
}
}
Expand Down