fix: prevent vite from crashing where there are no support files or specs found (#17624)

* fix: no supportfile + no specs, vite don't crash

When there is no values, in the optimization array,
supportFile can be a boolean. the final optimized entry passed to
fast-glog is then `[false]` whic crashes cypress.

This protects against the no-spec issue

closes #17373

* fix: protect startServer from undefined specs
This commit is contained in:
Barthélémy Ledoux
2021-08-06 15:46:00 -05:00
committed by GitHub
parent 750ea59a1f
commit ae0ea87802

View File

@@ -59,7 +59,9 @@ const resolveServerConfig = async ({ viteConfig, options }: StartDevServerOption
// Ask vite to pre-optimize all dependencies of the specs
finalConfig.optimizeDeps = finalConfig.optimizeDeps || {}
finalConfig.optimizeDeps.entries = [...options.specs.map((spec) => spec.relative), supportFile]
if ((options.specs && options.specs.length) || supportFile) {
finalConfig.optimizeDeps.entries = [...options.specs.map((spec) => spec.relative), supportFile]
}
debug(`the resolved server config is ${JSON.stringify(finalConfig, null, 2)}`)