javascript - Webpack Encore 与 Babel
问题描述
我在浏览器控制台中收到以下错误:
未捕获的 ReferenceError:未定义 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 功能来说,这一切都变得有点过分了。在我的浏览器中运行的功能。
解决方案
推荐阅读
- python - 为什么 python 2 和 3 对于某些十六进制值有不同的打印输出?
- python-3.x - 使用 Pandas 找到每个唯一组的最高值
- javascript - 我的请假申请表中的回形针选项以附加文件
- android - 如何在滑动刷新布局中检索特定用户
- sql-server - DBeaver 连接已关闭 MS SQL
- java - Java 只通过一个对象发送类参数
- dialog - 如何编写代码“如果我在对话框中单击“取消”,对话框将关闭,该字段将不显示任何内容。”?
- python - 在 Ubuntu 上降级 Python 版本
- html - 用于将样式应用于多个元素但也使用 id 的类,我们可以应用样式。有什么区别?
- html - 在 innerHTML 中编译模板字符串