-
-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Description
Describe the bug
Currently in the Ember project we are using the command vite optimize to verify that all the dependencies are being optimised correctly (see this test file if you're curious). With the recent deprecation of the vite optimize command #19348 we need a way to be able to verify the dependency optimisation step passes without error in our CI.
We can't rely on vite dev for this information because an esbuild plugin fails for any reason that dependency just gets externalised and will be re-loaded once the Vite dev server starts. You can see that behaviour in the linked reproduction.
Even if we don't make vite dev always fail for people if esbuild fails (maybe this is a default that might need to wait for a major?) we would love the ability to pass an arg that would opt-in to this behaviour e.g. vite dev --brittle or something
Reproduction
https://stackblitz.com/edit/vitejs-vite-tb94xq8d?file=vite.config.js
Steps to reproduce
- run npm install
- run npx vite dev
- observe that the esbuild fails and logs in the terminal
- observe that the vite dev server succeeds and serves the app
System Info
This is just taken from the stackblitz link above:
System:
OS: Linux 5.0 undefined
CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Memory: 0 Bytes / 0 Bytes
Shell: 1.0 - /bin/jsh
Binaries:
Node: 18.20.3 - /usr/local/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 10.2.3 - /usr/local/bin/npm
pnpm: 8.15.6 - /usr/local/bin/pnpm
npmPackages:
vite: ^6.0.0 => 6.0.11Used Package Manager
npm
Logs
VITE v6.0.11 ready in 1069 ms
➜ Local: http://localhost:5173/
➜ Network: use --host to expose
➜ press h + enter to show help
Error: Failed to scan for dependencies from entries:
/home/projects/vitejs-vite-tb94xq8d/index.html
✘ [ERROR] oops [plugin example]
node_modules/esbuild/lib/main.js:1216:27:
1216 │ let result = await callback({
╵ ^
at eval (file:///home/projects/vitejs-vite-tb94xq8d/node_modules/.vite-temp/vite.config.js.timestamp-1738762350011-5946a081b8f51.mjs:21:17)
at requestCallbacks.on-resolve (/home/projects/vitejs-vite-tb94xq8d/node_modules/esbuild/lib/main.js:1216:28)
at handleRequest (/home/projects/vitejs-vite-tb94xq8d/node_modules/esbuild/lib/main.js:637:17)
at handleIncomingPacket (/home/projects/vitejs-vite-tb94xq8d/node_modules/esbuild/lib/main.js:662:7)
at Socket.readFromStdout (/home/projects/vitejs-vite-tb94xq8d/node_modules/esbuild/lib/main.js:590:7)
at Socket.emit (node:events:30:10899)
at addChunk (node:internal/streams/readable:225:3685)
at readableAddChunk (node:internal/streams/readable:225:3393)
at Readable.push (node:internal/streams/readable:225:4971)
at _0x1e0a15.onStreamRead (node:internal/stream_base_commons:211:2596)
This error came from the "onResolve" callback registered here:
node_modules/esbuild/lib/main.js:1140:20:
1140 │ let promise = setup({
╵ ^
at setup (file:///home/projects/vitejs-vite-tb94xq8d/node_modules/.vite-temp/vite.config.js.timestamp-1738762350011-5946a081b8f51.mjs:19:13)
at handlePlugins (/home/projects/vitejs-vite-tb94xq8d/node_modules/esbuild/lib/main.js:1140:21)
at buildOrContextImpl (/home/projects/vitejs-vite-tb94xq8d/node_modules/esbuild/lib/main.js:863:5)
at Object.buildOrContext (/home/projects/vitejs-vite-tb94xq8d/node_modules/esbuild/lib/main.js:689:5)
at eval (/home/projects/vitejs-vite-tb94xq8d/node_modules/esbuild/lib/main.js:1844:68)
at <anonymous> (https://vitejsvitetb94xq8d-qpd2.w-credentialless-staticblitz.com/blitz.d20a0a75.js:40:25239)
at new Promise (https://vitejsvitetb94xq8d-qpd2.w-credentialless-staticblitz.com/blitz.d20a0a75.js:40:25210)
at Object.context (/home/projects/vitejs-vite-tb94xq8d/node_modules/esbuild/lib/main.js:1844:27)
The plugin "example" was triggered by this import
src/main.js:4:29:
4 │ import { setupCounter } from './counter.js';
╵ ~~~~~~~~~~~~~~
at failureErrorWithLog (/home/projects/vitejs-vite-tb94xq8d/node_modules/esbuild/lib/main.js:1466:15)
at eval (/home/projects/vitejs-vite-tb94xq8d/node_modules/esbuild/lib/main.js:935:25)
at runOnEndCallbacks (/home/projects/vitejs-vite-tb94xq8d/node_modules/esbuild/lib/main.js:1306:45)
at buildResponseToResult (/home/projects/vitejs-vite-tb94xq8d/node_modules/esbuild/lib/main.js:933:7)
at eval (/home/projects/vitejs-vite-tb94xq8d/node_modules/esbuild/lib/main.js:945:9)
at <anonymous> (https://vitejsvitetb94xq8d-qpd2.w-credentialless-staticblitz.com/blitz.d20a0a75.js:40:25239)
at new Promise (https://vitejsvitetb94xq8d-qpd2.w-credentialless-staticblitz.com/blitz.d20a0a75.js:40:25210)
at requestCallbacks.on-end (/home/projects/vitejs-vite-tb94xq8d/node_modules/esbuild/lib/main.js:944:54)
at handleRequest (/home/projects/vitejs-vite-tb94xq8d/node_modules/esbuild/lib/main.js:637:17)
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.