-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
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
Top Level await parsing failes #15869
Comments
Well I can say I solved the issue now, but with an unexpected outcome: |
Webpack by default considers a file without module.exports = {
mode: 'production',
entry: /* entries object, containing the .jsx files*/,
output: {
path: path.resolve(__dirname, `public/__js`),
filename: '[name].js',
},
module: {
rules: [{
test: /(\.jsx|\.js)$/,
include: path.resolve(__dirname, `src`),
type: "javascript/esm",
use: { Beware, to set |
Yes, we considered to remove "javascript/auto" for webpck v5, but it will be big breaking change for developers, so we decide to postpone it |
answered by @arthurdandrea 👍 |
if it is inside a |
Bug report
Enabling
experiments.topLevelAwait
and using the@babel/plugin-syntax-top-level-await
for parsing .jsx files does not work, and throws errorError: Top-level-await is only supported in EcmaScript Modules
What is the current behavior?
With this config:
using top-level await in the code throws an error
If the current behavior is a bug, please provide the steps to reproduce.
Since
experiments.topLevelAwait
is enabled, and the babel plugins are enabled, the error shouldn't appearWhat is the expected behavior?
Webpack should not throw the
Error: Top-level-await is only supported in EcmaScript Modules
error and compile the files successfullyOther relevant information:
webpack version: 5.72.1
Node.js version: 18.2.0
Operating System: Debian 10
Additional tools:
The text was updated successfully, but these errors were encountered: