feat(scripts): add harmony component placeholder injection logic
新增鸿蒙组件级componentPlaceholder自动注入脚本,解决diy组件编译为asyncComponent导致的运行时报错,自动遍历处理非页面组件的json配置文件,同时添加异常捕获避免构建中断
This commit is contained in:
@@ -58,6 +58,19 @@ async function copyAssets(mode = 'production') {
|
||||
}
|
||||
|
||||
await Promise.all(copyPromises);
|
||||
|
||||
// 给所有子组件 .json 注入 componentPlaceholder, 避免 "diy-* is asyncComponent" 报错.
|
||||
// 见 scripts/harmony-component-placeholder.js 说明. 该脚本跳过页面级, 只处理组件.
|
||||
try {
|
||||
const { execFileSync } = require('child_process');
|
||||
execFileSync(process.execPath, [
|
||||
path.join(__dirname, 'harmony-component-placeholder.js'),
|
||||
destDir,
|
||||
], { stdio: 'inherit', cwd });
|
||||
} catch (e) {
|
||||
console.warn('[harmony.patch] ⚠️ harmony-component-placeholder 注入失败:', e.message);
|
||||
}
|
||||
|
||||
console.log('HarmonyOS 资源拷贝完成');
|
||||
} catch (err) {
|
||||
console.error('发生错误:', err);
|
||||
|
||||
Reference in New Issue
Block a user