Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: The top-level-await experiment is not enabled (set experiments.topLevelAwait: true to enabled it) React-Intl for translation

Tags:

react-intl

Facing Below build issue:

Module parse failed: The top-level-await experiment is not enabled (set experiments.topLevelAwait: true to enabled it)

File was processed with these loaders:
 * ./node_modules/babel-loader/lib/index.js
 * ./node_modules/source-map-loader/dist/cjs.js
You may need an additional loader to handle the result of these loaders.
Error: The top-level-await experiment is not enabled (set experiments.topLevelAwait: true to enabled it)

Any please provide some solution for this ?

like image 279
Raunak Deep Srivastava Avatar asked Sep 03 '25 07:09

Raunak Deep Srivastava


1 Answers

I got this error when exporting a module with async. Just add this to the module.exports object in webpack.config.js file.

experiments: {
  topLevelAwait: true
}

You can also read up about the experiment option in Webpack documentation. https://webpack.js.org/configuration/experiments/

like image 60
Bello Tomi Avatar answered Sep 05 '25 01:09

Bello Tomi