Skip to content

top-level-await error using app directory #43382

@niicojs

Description

@niicojs

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

I'm using ky-universal in my project.
next@latest
node LTS (18)

What browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

pnpm

Describe the Bug

Using pages directory, everything works fine but as soon as I define experimental.appDir = true in next.config.js I have this error:

Module parse failed: The top-level-await experiment is not enabled (set experiments.topLevelAwait: true to enabled it)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file.
See https://webpack.js.org/concepts#loaders
Error: The top-level-await experiment is not enabled (set experiments.topLevelAwait: true to enabled it)

Expected Behavior

Just activating experimental pages should not alter anything in pages.

Link to reproduction - Issues with a link to complete (but minimal) reproduction code will be addressed faster

https://stackblitz.com/edit/nextjs-vwd7jz

To Reproduce

Example available here: https://stackblitz.com/edit/nextjs-vwd7jz
Just remove app dir in next config and it will work again.

NEXT-3126

Metadata

Metadata

Assignees

Labels

linear: nextConfirmed issue that is tracked by the Next.js team.locked

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions