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

next.config.ts does not support top-level-await #67765

Open
stefanprobst opened this issue Jul 15, 2024 · 4 comments · May be fixed by #68365
Open

next.config.ts does not support top-level-await #67765

stefanprobst opened this issue Jul 15, 2024 · 4 comments · May be fixed by #68365
Assignees
Labels
bug Issue was opened via the bug report template. TypeScript Related to types with Next.js.

Comments

@stefanprobst
Copy link
Contributor

Link to the code that reproduces this issue

https://github.com/stefanprobst/issue-next.config.ts-await

To Reproduce

ReferenceError: await is not defined

Current vs. Expected behavior

top-level await works in next.config.js but not in next.config.ts.

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #41~22.04.2-Ubuntu SMP PREEMPT_DYNAMIC Mon Jun  3 11:32:55 UTC 2
  Available memory (MB): 15893
  Available CPU cores: 4
Binaries:
  Node: 20.14.0
  npm: 10.7.0
  Yarn: N/A
  pnpm: 9.5.0
Relevant Packages:
  next: 15.0.0-canary.67 // Latest available version is detected (15.0.0-canary.67).
  eslint-config-next: N/A
  react: 19.0.0-rc.0
  react-dom: 19.0.0-rc.0
  typescript: 5.5.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

TypeScript

Which stage(s) are affected? (Select all that apply)

next dev (local)

Additional context

No response

@stefanprobst stefanprobst added the bug Issue was opened via the bug report template. label Jul 15, 2024
@github-actions github-actions bot added the TypeScript Related to types with Next.js. label Jul 15, 2024
@devjiwonchoi devjiwonchoi self-assigned this Jul 15, 2024
@devjiwonchoi
Copy link
Member

Thank you for reporting this! We will surely get this fixed before going stable. Thank you once again!

@devjiwonchoi devjiwonchoi linked a pull request Jul 31, 2024 that will close this issue
@karlhorky
Copy link
Contributor

karlhorky commented Sep 18, 2024

For anyone looking for a workaround for ESM / top-level await support until PR #68365 lands, I added a workaround with a node_modules patch here:

@stefanprobst
Copy link
Contributor Author

@karlhorky does https://nextjs.org/docs/app/api-reference/next-config-js#async-configuration work as a workaround for your usecase?

@karlhorky
Copy link
Contributor

karlhorky commented Sep 18, 2024

My use case (documented in my comments in #68365) is actually not even top-level await - it was an ESM-only library failing with ERR_PACKAGE_PATH_NOT_EXPORTED when imported in next.config.ts 😮

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template. TypeScript Related to types with Next.js.
Projects
None yet
3 participants