Open ChurchTao opened 3 months ago
我刚刚也遇到这个问题了,刚创建 taro4.0.4 的模板,引入 mp-html 就报错
webpack 直接把原生组件也进行二次编译了,目前还没找到手动忽略的方式,使用 compile.exclude,目前也没办法阻止 webpack 进行二次编译
确实,我也发现了
确实,我也发现了
目前我只能在 mini 配置中加入两个 wepback 插件实现
const config = {
mini: {
webpackChain(chain) {
chain.plugin('copyRawComponent').use(new CopyWebpackPlugin({
patterns: [{
from: path.resolve(__dirname, '../src/components/mp-html'), // 源目录
to: path.resolve(__dirname, '../dist/components/mp-html'), // 目标目录
}]
}))
chain.plugin('ignoreRawComponent').use(new IgnorePlugin({
resourceRegExp: /mp-html/
}))
}
}
}
相关平台
微信小程序
小程序基础库: 3.4.3 使用框架: React
复现步骤
pnpm dev:weapp
期望结果
正常编译
实际结果
✖ Errors:
resolve './{{ctrl[i]<0?opts[2]:opts[1]}}' in '/Users/churcht/WeChatProjects/lfhs-mini/src/components/mp-html/node' using description file: /Users/churcht/WeChatProjects/lfhs-mini/package.json (relative path: ./src/components/mp-html/node) resolve multi platform file path using description file: /Users/churcht/WeChatProjects/lfhs-mini/package.json (relative path: ./src/components/mp-html/node) Field 'browser' doesn't contain a valid alias configuration root path /Users/churcht/WeChatProjects/lfhs-mini using description file: /Users/churcht/WeChatProjects/lfhs-mini/package.json (relative path: ./Users/churcht/WeChatProjects/lfhs-mini/src/components/mp-html/node/{{ctrl[i]<0) no extension Field 'browser' doesn't contain a valid alias configuration /Users/churcht/WeChatProjects/lfhs-mini/Users/churcht/WeChatProjects/lfhs-mini/src/components/mp-html/node/{{ctrl[i]<0 doesn't exist .js Field 'browser' doesn't contain a valid alias configuration /Users/churcht/WeChatProjects/lfhs-mini/Users/churcht/WeChatProjects/lfhs-mini/src/components/mp-html/node/{{ctrl[i]<0.js doesn't exist .jsx Field 'browser' doesn't contain a valid alias configuration /Users/churcht/WeChatProjects/lfhs-mini/Users/churcht/WeChatProjects/lfhs-mini/src/components/mp-html/node/{{ctrl[i]<0.jsx doesn't exist .ts Field 'browser' doesn't contain a valid alias configuration /Users/churcht/WeChatProjects/lfhs-mini/Users/churcht/WeChatProjects/lfhs-mini/src/components/mp-html/node/{{ctrl[i]<0.ts doesn't exist .tsx Field 'browser' doesn't contain a valid alias configuration /Users/churcht/WeChatProjects/lfhs-mini/Users/churcht/WeChatProjects/lfhs-mini/src/components/mp-html/node/{{ctrl[i]<0.tsx doesn't exist .mjs Field 'browser' doesn't contain a valid alias configuration /Users/churcht/WeChatProjects/lfhs-mini/Users/churcht/WeChatProjects/lfhs-mini/src/components/mp-html/node/{{ctrl[i]<0.mjs doesn't exist .vue Field 'browser' doesn't contain a valid alias configuration /Users/churcht/WeChatProjects/lfhs-mini/Users/churcht/WeChatProjects/lfhs-mini/src/components/mp-html/node/{{ctrl[i]<0.vue doesn't exist as directory /Users/churcht/WeChatProjects/lfhs-mini/Users/churcht/WeChatProjects/lfhs-mini/src/components/mp-html/node/{{ctrl[i]<0 doesn't exist using description file: /Users/churcht/WeChatProjects/lfhs-mini/package.json (relative path: ./src/components/mp-html/node/{{ctrl[i]<0) no extension Field 'browser' doesn't contain a valid alias configuration /Users/churcht/WeChatProjects/lfhs-mini/src/components/mp-html/node/{{ctrl[i]<0 doesn't exist .js Field 'browser' doesn't contain a valid alias configuration /Users/churcht/WeChatProjects/lfhs-mini/src/components/mp-html/node/{{ctrl[i]<0.js doesn't exist .jsx Field 'browser' doesn't contain a valid alias configuration /Users/churcht/WeChatProjects/lfhs-mini/src/components/mp-html/node/{{ctrl[i]<0.jsx doesn't exist .ts Field 'browser' doesn't contain a valid alias configuration /Users/churcht/WeChatProjects/lfhs-mini/src/components/mp-html/node/{{ctrl[i]<0.ts doesn't exist .tsx Field 'browser' doesn't contain a valid alias configuration /Users/churcht/WeChatProjects/lfhs-mini/src/components/mp-html/node/{{ctrl[i]<0.tsx doesn't exist .mjs Field 'browser' doesn't contain a valid alias configuration /Users/churcht/WeChatProjects/lfhs-mini/src/components/mp-html/node/{{ctrl[i]<0.mjs doesn't exist .vue Field 'browser' doesn't contain a valid alias configuration /Users/churcht/WeChatProjects/lfhs-mini/src/components/mp-html/node/{{ctrl[i]<0.vue doesn't exist as directory /Users/churcht/WeChatProjects/lfhs-mini/src/components/mp-html/node/{{ctrl[i]<0 doesn't exist
→ Watching... [2024/8/15 18:15:23]
node:internal/process/promises:289 triggerUncaughtException(err, true / fromPromise /); ^
[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "[object Array]".] { code: 'ERR_UNHANDLED_REJECTION' }
环境信息