You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
create-cloudflare creates a next.js project with a top-level await in the config file. If typescript is selected, it causes a problem because top-level await can only be used inside a .mts or .mjs file, but the Next config is a .ts file and can't be a .mts file(1). A simple npm run dev causes:
ReferenceError: await is not defined
There is no problem if javascript is selected because next config is a .mjs file.
There is no problem if JavaScript is selected because the Next config is a .mjs file. I have proposed a solution at this comment. But the code block below says awaiting may not be necessary, so maybe we can delete the await and be done with it. In any case, the template engine should not output an invalid configuration.
if(process.env.NODE_ENV==='development'){// `await`ing the call is not necessary but it helps making sure that the setup has succeeded.// If you cannot use top level awaits you could use the following to avoid an unhandled rejection:// `setupDevPlatform().catch(e => console.error(e));`awaitsetupDevPlatform();}
Thanks for the issue and sorry for the late reply I just only now noticed it
Given this problem I think C3 should create a next.config.mjs file instead and use jsdocs for types, exactly how you did it here: cloudflare/next-on-pages#925 (comment)
Which Cloudflare product(s) does this pertain to?
C3 (npm create cloudflare)
What versions are you using?
2.35.1 [C3 - create-cloudflare@latest]
What operating system and version are you using?
Mac Sequoia 15.2
Please provide a link to a minimal reproduction
No response
Describe the Bug
npm create cloudflare@latest . --framework=next
create-cloudflare creates a next.js project with a top-level await in the config file. If typescript is selected, it causes a problem because top-level await can only be used inside a .mts or .mjs file, but the Next config is a .ts file and can't be a .mts file(1). A simple npm run dev causes:
There is no problem if javascript is selected because next config is a .mjs file.
There is no problem if JavaScript is selected because the Next config is a .mjs file. I have proposed a solution at this comment. But the code block below says awaiting may not be necessary, so maybe we can delete the await and be done with it. In any case, the template engine should not output an invalid configuration.
From: https://github.com/cloudflare/next-on-pages/blob/main/internal-packages/next-dev/README.md
If you give me directions, I can open a PR.
Please also see other issues at the next-on-pages repo with the same problem:
cloudflare/next-on-pages#927
cloudflare/next-on-pages#925
Please provide any relevant error logs
No response
The text was updated successfully, but these errors were encountered: