[Bug or Feature?] Top-Level Await Dynamic Import Incompatibility with Provide Plugin Causing Undefined Variables #19007
Unanswered
Kane-Kuroneko
asked this question in
Q&A
Replies: 3 comments 3 replies
-
just try to use await sync |
Beta Was this translation helpful? Give feedback.
0 replies
-
I know , but I suppose "This issue can be resolved by replacing await import() with require(), but this makes the ESM code impure." |
Beta Was this translation helpful? Give feedback.
0 replies
-
Unfortunately I can't help without a real example, it should work and we have tests on such cases, I'll temporarily move it to discussions, as soon as you provide an example we will try to understand why it doesn't work in your case |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Bug report
What is the current behavior?
All variables exported from an ESM that contains a top-level awaited dynamic import are undefined.
If the current behavior is a bug, please provide the steps to reproduce.
This case demonstrates that some logic depends on a dynamic module, and
something
is provided by ProvidePlugin, but it'sundefined
at runtime. This issue can be resolved by replacingawait import()
withrequire()
, but this makes the ESM code impure.What is the expected behavior?
Expect the provide-plugin to work correctly when a variable is exported from an ESM that contains a top-level awaited dynamic import.
Other relevant information:
webpack version: ^5.95.0
Node.js version: 23.1.0
Operating System: win11
Additional tools:
Beta Was this translation helpful? Give feedback.
All reactions