/** * 确保微信小程序产物 app.json 含 lazyCodeLoading(代码质量「组件按需注入」依赖此项) */ const fs = require('fs') const path = require('path') const root = path.join(__dirname, '..') const appJsonPath = path.join(root, 'dist/build/mp-weixin/app.json') if (!fs.existsSync(appJsonPath)) { console.error('[verify-mp-app-json] 未找到:', appJsonPath) process.exit(1) } const app = JSON.parse(fs.readFileSync(appJsonPath, 'utf8')) if (app.lazyCodeLoading !== 'requiredComponents') { console.error('[verify-mp-app-json] app.json 缺少 lazyCodeLoading: "requiredComponents",请检查 src/manifest.json 中 mp-weixin 配置后重新编译。') process.exit(1) } console.log('[verify-mp-app-json] OK:已启用组件按需注入 lazyCodeLoading')