esbuild: Unterminated string literal when building SSR bundle
See original GitHub issueDescribe the bug
This is an issue that first appeared for me 2 days ago, where all builds would fail because of a seemingly incomplete import statement in one specific file, where no such import statement existed. This could be fixed by deleting the file, starting the devserver, then adding the file back in while it’s running. This workaround, however as far as I know, is not practical when deploying to Vercel in this case, as it would probably take a script to run the dev server with the file deleted, then subsequently readding it.
To the best of my knowledge, this does not have anything to do with vite, since I was unable to reproduce it with the SSR projects provided.
Reproduction
A copy of the project is on https://github.com/murl-digital/draconium.productions-mirror, and the problem has to do with /src/routes/index.svelte.
Logs
vite v2.8.3 building SSR bundle for production...
✘ [ERROR] Unterminated string literal
html:/vercel/path0/src/routes/index.svelte:21:8:
21 │ import "
╵ ^
> Build failed with 1 error:
html:/vercel/path0/src/routes/index.svelte:21:8: ERROR: Unterminated string literal
html:/vercel/path0/src/routes/index.svelte:21:8: ERROR: Unterminated string literal
at failureErrorWithLog (/vercel/path0/node_modules/.pnpm/esbuild@0.14.22/node_modules/esbuild/lib/main.js:1602:15)
at /vercel/path0/node_modules/.pnpm/esbuild@0.14.22/node_modules/esbuild/lib/main.js:1248:28
at runOnEndCallbacks (/vercel/path0/node_modules/.pnpm/esbuild@0.14.22/node_modules/esbuild/lib/main.js:1033:63)
at buildResponseToResult (/vercel/path0/node_modules/.pnpm/esbuild@0.14.22/node_modules/esbuild/lib/main.js:1246:7)
at /vercel/path0/node_modules/.pnpm/esbuild@0.14.22/node_modules/esbuild/lib/main.js:1355:14
at /vercel/path0/node_modules/.pnpm/esbuild@0.14.22/node_modules/esbuild/lib/main.js:665:9
at handleIncomingPacket (/vercel/path0/node_modules/.pnpm/esbuild@0.14.22/node_modules/esbuild/lib/main.js:762:9)
at Socket.readFromStdout (/vercel/path0/node_modules/.pnpm/esbuild@0.14.22/node_modules/esbuild/lib/main.js:632:7)
at Socket.emit (events.js:400:28)
at addChunk (internal/streams/readable.js:293:12)
System Info
Unable to run on Vercel, but here’s my local machine where I also encountered this bug on.
System:
OS: Windows 10 10.0.22000
CPU: (16) x64 AMD Ryzen 7 3700X 8-Core Processor
Memory: 38.76 GB / 63.92 GB
Binaries:
Node: 17.4.0 - C:\Program Files\nodejs\node.EXE
npm: 8.3.0 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: Spartan (44.22000.120.0), Chromium (98.0.1108.55)
Internet Explorer: 11.0.22000.120
npmPackages:
@sveltejs/adapter-vercel: next => 1.0.0-next.43
@sveltejs/kit: next => 1.0.0-next.278
svelte: ^3.46.4 => 3.46.4
vite: ^2.8.3 => 2.8.3
Severity
blocking all usage of SvelteKit
Additional Information
No response
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (3 by maintainers)

Top Related StackOverflow Question
As ben said, thanks @CaptainCodeman! The fix works perfectly and I’ve had no other issues
Thanks @CaptainCodeman! That investigation sped things up for me quite a bit. I sent a fix for the issue here: https://github.com/vitejs/vite/pull/7202