diff --git a/packages/uni-cli-shared/__tests__/cache.spec.js b/packages/uni-cli-shared/__tests__/cache.spec.js index 3ab10ff484..af554befc1 100644 --- a/packages/uni-cli-shared/__tests__/cache.spec.js +++ b/packages/uni-cli-shared/__tests__/cache.spec.js @@ -80,31 +80,31 @@ describe('shared:cache', () => { }) it('mp-toutiao generate component.json', () => { + const prevPlatform = process.env.UNI_PLATFORM process.env.UNI_PLATFORM = 'mp-toutiao' - const name = 'components/component-tag-name' + // 独立 name:覆盖 add 与 update。不得再强制注入 componentPlaceholder(#6057) + const name = 'components/toutiao-no-force-placeholder' let usingComponents = { 'my-component': '/components/component-tag-name' } - const componentPlaceholder = { - 'my-component': 'view' - } updateUsingComponents(name, usingComponents, 'Component') let componentJsonStr = getChangedJsonFileMap().get(name + '.json') expect(componentJsonStr).toBe(JSON.stringify({ usingComponents, - component: true, - componentPlaceholder + component: true }, null, 2)) expect(0).toBe(getChangedJsonFileMap().size) - usingComponents = {} + usingComponents = { + 'u-icon': '/components/u-icon' + } updateUsingComponents(name, usingComponents, 'Component') componentJsonStr = getChangedJsonFileMap().get(name + '.json') expect(componentJsonStr).toBe(JSON.stringify({ usingComponents, - component: true, - componentPlaceholder + component: true }, null, 2)) expect(0).toBe(getChangedJsonFileMap().size) + process.env.UNI_PLATFORM = prevPlatform }) }) diff --git a/packages/uni-cli-shared/lib/cache.js b/packages/uni-cli-shared/lib/cache.js index ff34a0213c..54f28e25da 100644 --- a/packages/uni-cli-shared/lib/cache.js +++ b/packages/uni-cli-shared/lib/cache.js @@ -200,18 +200,6 @@ function updateUsingComponents (name, usingComponents, type, content = '') { } if (oldJsonStr) { // update jsonObj.usingComponents = usingComponents - // 嵌套组件获取 props 为 null,使用占组件修正父子组件生命周期执行顺序 https://developer.open-douyin.com/docs/resource/zh-CN/mini-app/develop/tutorial/custom-component/placeholder - if (process.env.UNI_PLATFORM === 'mp-toutiao') { - if (type === 'Component') { - const usingComponentnames = Object.keys(jsonObj.usingComponents) - if (usingComponentnames.length) { - jsonObj.componentPlaceholder = {} - usingComponentnames.forEach(componentName => { - jsonObj.componentPlaceholder[componentName] = 'view' - }) - } - } - } const newJsonStr = JSON.stringify(jsonObj, null, 2) if (newJsonStr !== oldJsonStr) { updateJsonFile(name, newJsonStr)