Skip to content

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

@acarl005

Description

@acarl005

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingp1-importantSvelteKit cannot be used by a large number of people, basic functionality is missing, etc.pkg:adapter-vercelPertaining to the Vercel adapter

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions