使用 Babel 的 Webpack Encore

问题描述

我在浏览器控制台中收到以下错误:

未捕获的引用错误:未定义 regeneratorRuntime

我在这里找到了一个问题和答案,上面说要安装 Babel 以使其正常工作,所以我开始这样做。现在就上下文而言,我以前从未使用过 Webpack Encore 或 Babel。我从来不需要。我将以下几行添加到我的 Webpack Encore 文件中,但出现了另一个错误。

Encore.configureBabel(() => {},{
    useBuiltIns: 'usage',})
[ encore ] Module build failed (from ./node_modules/babel-loader/lib/index.js):
RangeError: [BABEL] \resources\js\app.ts: Invalid Option: The version passed to `corejs` is invalid. Currently,only core-js@2 and core-js@3 are supported. (While processing: "\\node_modules\\@babel\\preset-env\\lib\\index.js")
    at normalizeCoreJSOption (\node_modules\@babel\preset-env\lib\normalize-options.js:114:11)
    at normalizeOptions (\node_modules\@babel\preset-env\lib\normalize-options.js:126:18)
    at \node_modules\@babel\preset-env\lib\index.js:271:37
    at \node_modules\@babel\helper-plugin-utils\lib\index.js:22:12
    at async (\node_modules\@babel\core\lib\gensync-utils\async.js:43:33)
    at async (\node_modules\gensync\index.js:186:15)
    at \node_modules\gensync\index.js:216:13
    at Generator.next (<anonymous>)
    at \node_modules\@babel\core\lib\config\full.js:217:21
    at Generator.next (<anonymous>)

由于该错误,我在 corejs: '3.0.0', 下方添加了 useBuiltIns,但出现了更多错误。我发现的另一个问题表明,corejs 只会使 useBuiltIns: 'usage' 过时。

这对于 async/await 功能来说有点太多了。在我的浏览器中运行的功能。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...