diff --git a/packages/uni-cli-shared/src/json/mp/jsonFile.ts b/packages/uni-cli-shared/src/json/mp/jsonFile.ts index d4fe88a1c41e740cc7ca5fff643ef8ff6aee608b..26279cb85e1286b45d0e446296794627d0e45112 100644 --- a/packages/uni-cli-shared/src/json/mp/jsonFile.ts +++ b/packages/uni-cli-shared/src/json/mp/jsonFile.ts @@ -42,13 +42,16 @@ export function findChangedJsonFiles() { newJson.usingComponents = {} } extend(newJson.usingComponents, jsonUsingComponentsCache.get(filename)) - const usingComponents = newJson.usingComponents + const usingComponents = newJson.usingComponents as Record // 格式化为相对路径,这样作为分包也可以直接运行 Object.keys(usingComponents).forEach((name) => { - usingComponents[name] = relativeFile( - filename, - usingComponents[name].slice(1) - ) + const componentFilename = usingComponents[name] + if (componentFilename.startsWith('/')) { + usingComponents[name] = relativeFile( + filename, + componentFilename.slice(1) + ) + } }) const jsonStr = JSON.stringify(newJson, null, 2)