Laravel 9 mix:如何使用async await组件?



我在网上找不到任何人来解释如何在laravel mix中添加experimental await组件。

My error:

ERROR in ./resources/js/departements_search.js
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
You may need an additional loader to handle the result of these loaders.

我发现了这个:

module.exports = {
//...
experiments: {
asyncWebAssembly: true,
buildHttp: true,
layers: true,
lazyCompilation: true,
outputModule: true,
syncWebAssembly: true,
topLevelAwait: true,
},
};

但我不明白如何设置?我的webpack。配置似乎根本不起作用。如何添加此功能,如:

mix.webpackConfig({
// something here
});

提前感谢。

在您的webpack.mix.js中添加:

mix.webpackConfig({
// ... existing stuff (optional)
,
experiments: {
topLevelAwait: true
}

相关内容

  • 没有找到相关文章

最新更新