fix: 缺少 npm 构建产物时模板产物校验只告警
This commit is contained in:
1 parent
2325214078
commit
784b9cbac8
2 files changed
+45
-3
No files matched your search
@@ -299,7 +299,7 @@ function resolveRequire(output, fromFile, reference) {
|
||||
}
|
||||
|
||||
/** 校验产物可以被微信开发者工具直接打开:页面、组件、require、图标和模板隔离。 */
|
||||
function validateOutput(output, appJson, packageKey) {
|
||||
export function validateOutput(output, appJson, packageKey) {
|
||||
const errors = [];
|
||||
const warnings = [];
|
||||
for (const page of appJson.pages) {
|
||||
@@ -325,11 +325,15 @@ function validateOutput(output, appJson, packageKey) {
|
||||
if (file.endsWith(".json") && (file.startsWith("pages/") || file.startsWith("components/"))) {
|
||||
const usingComponents = JSON.parse(source).usingComponents || {};
|
||||
for (const [name, reference] of Object.entries(usingComponents)) {
|
||||
if (reference.startsWith("/miniprogram_npm/") && !hasNpm) {
|
||||
if (reference.startsWith("plugin://")) continue;
|
||||
// miniprogram_npm 由微信开发者工具生成且不入库;缺失时只能提示,不能把干净检出判为失败。
|
||||
const needsNpm =
|
||||
reference.startsWith("/miniprogram_npm/") ||
|
||||
(!reference.startsWith("/") && !reference.startsWith("."));
|
||||
if (needsNpm && !hasNpm) {
|
||||
warnings.push(`${file}: ${name} needs miniprogram_npm (build npm in apps/miniapp first)`);
|
||||
continue;
|
||||
}
|
||||
if (reference.startsWith("plugin://")) continue;
|
||||
if (!resolveComponent(output, file, reference))
|
||||
errors.push(`${file}: component ${name} cannot be resolved (${reference})`);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user