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

adapter-vercel — ERROR: Top-level await is currently not supported with the "cjs" output format #5017

Closed
acarl005 opened this issue May 21, 2022 · 4 comments · Fixed by #4969
Labels
bug Something isn't working p1-important SvelteKit cannot be used by a large number of people, basic functionality is missing, etc. pkg:adapter-vercel Pertaining to the Vercel adapter
Milestone

Comments

@acarl005
Copy link

acarl005 commented May 21, 2022

Describe the bug

When building the app with @sveltejs/adapter-vercel, and when I use top-level await in my server routes, I get this error:

.svelte-kit/output/server/entries/endpoints/helloworld.js:1:0: ERROR: Top-level await is currently not supported with the "cjs" output format

However, my package.json specifies "type": "module", but it still thinks I'm using cjs when I'm not.

Reproduction

https://stackblitz.com/edit/sveltejs-kit-template-default-qgneqz?file=src/routes/helloworld.js

Then, run npm run build

Logs

npm run build
.svelte-kit/output/server/entries/endpoints/helloworld.js:1:0: ERROR: Top-level await is currently not supported with the "cjs" output format

System Info

See my StackBlitz link

https://stackblitz.com/edit/sveltejs-kit-template-default-qgneqz?file=svelte.config.js,src%2Froutes%2Fhelloworld.js&terminal=dev

Severity

serious, but I can work around it

Additional Information

I'm using the recommended setup for a new sveltekit app, for which ECMA modules are encourages. That being the case, I believe the module features which are now built into node.js, like top-level await, should be usable.

@Rich-Harris
Copy link
Member

Ah, I forgot there was a reason for holding off on merging #4967. #4969 would fix this, but it causes certain builds to hang in a way that I don't currently understand.

For the time being, I'd recommend pinning to 1.0.0-next.52 or 51.

@acarl005
Copy link
Author

Thanks for the response, Rich! Pinning to 1.0.0-next.52 worked.

@mrkishi mrkishi linked a pull request May 22, 2022 that will close this issue
6 tasks
@mrkishi mrkishi added bug Something isn't working pkg:adapter-vercel Pertaining to the Vercel adapter p1-important SvelteKit cannot be used by a large number of people, basic functionality is missing, etc. labels May 22, 2022
@mrkishi mrkishi added this to the 1.0 milestone May 22, 2022
@furudean
Copy link
Contributor

furudean commented May 25, 2022

@Rich-Harris This seems to still happen with @sveltejs/adapter-vercel@1.0.0-next.56 and @sveltejs/kit@1.0.0-next.345

> Build failed with 1 error:
.svelte-kit/output/server/entries/matchers/entry.js:6:20: ERROR: Top-level await is currently not supported with the "cjs" output format
.svelte-kit/output/server/entries/matchers/entry.js:6:20: ERROR: Top-level await is currently not supported with the "cjs" output format
    at failureErrorWithLog (/Users/meri/Code/stemwringer/node_modules/esbuild/lib/main.js:1600:15)
    at /Users/meri/Code/stemwringer/node_modules/esbuild/lib/main.js:1246:28
    at runOnEndCallbacks (/Users/meri/Code/stemwringer/node_modules/esbuild/lib/main.js:1159:65)
    at buildResponseToResult (/Users/meri/Code/stemwringer/node_modules/esbuild/lib/main.js:1244:7)
    at /Users/meri/Code/stemwringer/node_modules/esbuild/lib/main.js:1353:14
    at /Users/meri/Code/stemwringer/node_modules/esbuild/lib/main.js:663:9
    at handleIncomingPacket (/Users/meri/Code/stemwringer/node_modules/esbuild/lib/main.js:760:9)
    at Socket.readFromStdout (/Users/meri/Code/stemwringer/node_modules/esbuild/lib/main.js:629:7)
    at Socket.emit (node:events:527:28)
    at Socket.emit (node:domain:475:12)

@furudean
Copy link
Contributor

furudean commented May 26, 2022

Could this issue be reopened? @Rich-Harris

I think #4967 being merged is what caused this to show up again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working p1-important SvelteKit cannot be used by a large number of people, basic functionality is missing, etc. pkg:adapter-vercel Pertaining to the Vercel adapter
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants