Skip to content

Commit 02a46d7

Browse files
authoredMar 24, 2023
fix: throw error on build optimizeDeps issue (#12560)
1 parent a326ec8 commit 02a46d7

File tree

1 file changed

+6
-18
lines changed

1 file changed

+6
-18
lines changed
 

‎packages/vite/src/node/plugins/optimizedDeps.ts

+6-18
Original file line numberDiff line numberDiff line change
@@ -116,31 +116,19 @@ export function optimizedDepsBuildPlugin(config: ResolvedConfig): Plugin {
116116
// If all the inputs are dependencies, we aren't going to get any
117117
const info = optimizedDepInfoFromFile(depsOptimizer.metadata, file)
118118
if (info) {
119-
try {
120-
// This is an entry point, it may still not be bundled
121-
await info.processing
122-
} catch {
123-
// If the refresh has not happened after timeout, Vite considers
124-
// something unexpected has happened. In this case, Vite
125-
// returns an empty response that will error.
126-
// throwProcessingError(id)
127-
return
128-
}
119+
await info.processing
129120
isDebug && debug(`load ${colors.cyan(file)}`)
130121
} else {
131-
// TODO: error
132-
return
122+
throw new Error(
123+
`Something unexpected happened while optimizing "${id}".`,
124+
)
133125
}
134126

135127
// Load the file from the cache instead of waiting for other plugin
136128
// load hooks to avoid race conditions, once processing is resolved,
137129
// we are sure that the file has been properly save to disk
138-
try {
139-
return await fs.readFile(file, 'utf-8')
140-
} catch (e) {
141-
// Outdated non-entry points (CHUNK), loaded after a rerun
142-
return ''
143-
}
130+
131+
return await fs.readFile(file, 'utf-8')
144132
},
145133
}
146134
}

0 commit comments

Comments
 (0)
Please sign in to comment.