Laravel 9混合:如何使用异步等待组成?

发布于 2025-02-09 12:19:16 字数 900 浏览 2 评论 0原文

我在网络中没有发现任何人可以解释如何添加外科视图等待Laravel Mix的组成。

我的错误:

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.config似乎根本没有起作用。如何添加此功能,例如:

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

谢谢。

I don't find anywere in the web someone to explain how to add exoperiment await componnent to laravel mix.

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.

I found this :

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

But I don't understand how to setup ? My webpack.config seem not working at all. How to add this feature like :

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

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一百个冬季 2025-02-16 12:19:16

在您的webpack.mix.js中,添加以下内容:

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

In your webpack.mix.js, add this:

mix.webpackConfig({
    // ... existing stuff (optional)
    ,
    experiments: {
        topLevelAwait: true
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文