-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
vite6 [commonjs--resolver] node_modules/testb/a.js (1:6): await isn't allowed in non-async function #18850
Comments
It doesn't work with Vite v5 too. I don't think this should work because top-level await cannot be used in CJS (nodejs/node#21267). |
Have you tried the build mode?
…---- Replied Message ----
| From | ***@***.***> |
| Date | 12/02/2024 09:28 |
| To | vitejs/vite ***@***.***> |
| Cc | zhn ***@***.***>,
Author ***@***.***> |
| Subject | Re: [vitejs/vite] vite6 [commonjs--resolver] node_modules/testb/a.js (1:6): await isn't allowed in non-async function (Issue #18850) |
It doesn't work with Vite v5 too.
https://stackblitz.com/edit/github-441yb3?file=package.json&terminal=build
I don't think this should work because top-level await cannot be used in CJS (nodejs/node#21267).
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Yes, I have. |
I don't have a computer with me right now. I'll check it tonight
…---- Replied Message ----
| From | ***@***.***> |
| Date | 12/02/2024 09:33 |
| To | vitejs/vite ***@***.***> |
| Cc | zhn ***@***.***>,
Author ***@***.***> |
| Subject | Re: [vitejs/vite] vite6 [commonjs--resolver] node_modules/testb/a.js (1:6): await isn't allowed in non-async function (Issue #18850) |
Yes, I have.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
My code is very simple. I think as long as Vite can skip the checks, vite-plugin-top-level-await can handle it. const remoteReact = await moduleFederation.import('react', "^18.0.1")
module.exports = remoteReact |
However, if there are other ways to implement this runtime module, I’m more than happy to make changes. |
Describe the bug
Everything works fine with Vite 5.
Top-level await in node_modules.
module-federation/vite#201
Reproduction
https://github.com/zhangHongEn/vite-mf-bug
Steps to reproduce
npm install && npm run build
System Info
Used Package Manager
npm
Logs
Validations
The text was updated successfully, but these errors were encountered: