Kar*_*rek 3 webpacker ruby-on-rails-6
我正在尝试将包导入到我的 Rails 6 项目 \xe2\x80\x93 我正在使用Rails 6.0.3.4gem webpacker 5.2.1。
yarn add @shopify/react-formimport {useForm, useField} from \'@shopify/react-form\';./bin/webpack-dev-server我明白了:
\nERROR in ./node_modules/@shopify/react-form/build/esm/validation/validator.mjs 35:25-32\nCan\'t import the named export \'isEmpty\' from non EcmaScript module (only default export is available)\nRun Code Online (Sandbox Code Playgroud)\n还有一些相同的错误但文件名不同。
\n我在另一个问题上读到添加新规则webpack可以解决该问题,因此我按照自述文件中的说明进行操作webpacker:\n
问题是我没有/config/webpack/base.js,无论如何我创建了并在目录rules中创建了一个目录/config/webpack/,所以我的base.js看起来像这样:
ERROR in ./node_modules/@shopify/react-form/build/esm/validation/validator.mjs 35:25-32\nCan\'t import the named export \'isEmpty\' from non EcmaScript module (only default export is available)\nRun Code Online (Sandbox Code Playgroud)\n修复如下所示:
\n// /config/webpack/base.js\nconst { webpackConfig, merge } = require(\'@rails/webpacker\')\nconst fixConfig = require(\'./rules/fix\')\n\nmodule.exports = merge(webpackConfig, fixConfig)\nRun Code Online (Sandbox Code Playgroud)\n我需要帮助/指导来找出解决这个问题的方法。蒂亚!
\n我设法修复了错误,这篇文章指导我弄清楚如何将新规则合并到 webpack 配置中。
environment.js现在看起来是这样的:
// /config/webpack/environment.js
const { environment } = require('@rails/webpacker')
environment.config.merge({
module: {
rules: [
{
test: /\.mjs$/,
include: /node_modules/,
type: "javascript/auto"
}
]
}
})
module.exports = environment
Run Code Online (Sandbox Code Playgroud)
之前是:
const { environment } = require('@rails/webpacker')
module.exports = environment
Run Code Online (Sandbox Code Playgroud)
我最终删除了base.js和fix.js。
| 归档时间: |
|
| 查看次数: |
2449 次 |
| 最近记录: |