Skip to content

Commit

Permalink
fix(template): 修复模板在最后一层递归时没有包裹 container 的问题, 修复 CustomWrapper 引用位置错…
Browse files Browse the repository at this point in the history
…误的问题 (#14369)

* fix(template): 修复模板在最后一层递归时没有包裹 container 的问题

* fix(template): 修复模板最大层数错误的问题

* fix(template): 修复 CustomWrapper 引用位置错误的问题

---------

Co-authored-by: xuanzebin <xuanzebin3@jd.com>
Co-authored-by: chenjiajian <798095202@qq.com>
  • Loading branch information
3 people authored Aug 16, 2023
1 parent f3c289c commit 2dae08a
Show file tree
Hide file tree
Showing 34 changed files with 169 additions and 3 deletions.
6 changes: 5 additions & 1 deletion packages/shared/src/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,8 @@ export class UnRecursiveTemplate extends BaseTemplate {
const componentsAlias = this.componentsAlias
const listA = Array.from(isLoopCompsSet).map(item => componentsAlias[item]?._num || item)
const listB = hasMaxComps.map(item => componentsAlias[item]?._num || item)

const containerLevel = this.baseLevel - 1

return `function (l, n, s) {
var a = ${JSON.stringify(listA)}
var b = ${JSON.stringify(listB)}
Expand All @@ -685,6 +686,9 @@ export class UnRecursiveTemplate extends BaseTemplate {
}
l = depth
}
if (l === ${containerLevel}) {
return 'tmpl_${containerLevel}_${Shortcuts.Container}'
}
return 'tmpl_' + l + '_' + n
}`
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1375,6 +1375,9 @@ module.exports = {
}
l = depth
}
if (l === 15) {
return 'tmpl_15_container'
}
return 'tmpl_' + l + '_' + n
},
b: function (a, b) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1461,6 +1461,9 @@ module.exports = {
}
l = depth
}
if (l === 15) {
return 'tmpl_15_container'
}
return 'tmpl_' + l + '_' + n
},
b: function (a, b) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1370,6 +1370,9 @@ module.exports = {
}
l = depth
}
if (l === 15) {
return 'tmpl_15_container'
}
return 'tmpl_' + l + '_' + n
},
b: function (a, b) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1541,6 +1541,9 @@ module.exports = {
}
l = depth
}
if (l === 19) {
return 'tmpl_19_container'
}
return 'tmpl_' + l + '_' + n
},
b: function (a, b) {
Expand Down Expand Up @@ -3201,6 +3204,9 @@ module.exports = {
}
l = depth
}
if (l === 15) {
return 'tmpl_15_container'
}
return 'tmpl_' + l + '_' + n
},
b: function (a, b) {
Expand Down Expand Up @@ -4751,6 +4757,9 @@ module.exports = {
}
l = depth
}
if (l === 15) {
return 'tmpl_15_container'
}
return 'tmpl_' + l + '_' + n
},
b: function (a, b) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1401,6 +1401,9 @@ module.exports = {
}
l = depth
}
if (l === 15) {
return 'tmpl_15_container'
}
return 'tmpl_' + l + '_' + n
},
b: function (a, b) {
Expand Down Expand Up @@ -2961,6 +2964,9 @@ module.exports = {
}
l = depth
}
if (l === 15) {
return 'tmpl_15_container'
}
return 'tmpl_' + l + '_' + n
},
b: function (a, b) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1671,6 +1671,9 @@ module.exports = {
}
l = depth
}
if (l === 15) {
return 'tmpl_15_container'
}
return 'tmpl_' + l + '_' + n
},
b: function (a, b) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1593,6 +1593,9 @@ module.exports = {
}
l = depth
}
if (l === 15) {
return 'tmpl_15_container'
}
return 'tmpl_' + l + '_' + n
},
b: function (a, b) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1375,6 +1375,9 @@ module.exports = {
}
l = depth
}
if (l === 15) {
return 'tmpl_15_container'
}
return 'tmpl_' + l + '_' + n
},
b: function (a, b) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2741,6 +2741,9 @@ module.exports = {
}
l = depth
}
if (l === 15) {
return 'tmpl_15_container'
}
return 'tmpl_' + l + '_' + n
},
b: function (a, b) {
Expand Down Expand Up @@ -5679,6 +5682,9 @@ module.exports = {
}
l = depth
}
if (l === 15) {
return 'tmpl_15_container'
}
return 'tmpl_' + l + '_' + n
},
b: function (a, b) {
Expand Down Expand Up @@ -8617,6 +8623,9 @@ module.exports = {
}
l = depth
}
if (l === 15) {
return 'tmpl_15_container'
}
return 'tmpl_' + l + '_' + n
},
b: function (a, b) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2044,6 +2044,9 @@ module.exports = {
}
l = depth
}
if (l === 15) {
return 'tmpl_15_container'
}
return 'tmpl_' + l + '_' + n
},
b: function (a, b) {
Expand Down Expand Up @@ -4253,6 +4256,9 @@ module.exports = {
}
l = depth
}
if (l === 15) {
return 'tmpl_15_container'
}
return 'tmpl_' + l + '_' + n
},
b: function (a, b) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1980,6 +1980,9 @@ module.exports = {
}
l = depth
}
if (l === 15) {
return 'tmpl_15_container'
}
return 'tmpl_' + l + '_' + n
},
b: function (a, b) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1382,6 +1382,9 @@ module.exports = {
}
l = depth
}
if (l === 15) {
return 'tmpl_15_container'
}
return 'tmpl_' + l + '_' + n
},
b: function (a, b) {
Expand Down Expand Up @@ -2929,6 +2932,9 @@ module.exports = {
}
l = depth
}
if (l === 15) {
return 'tmpl_15_container'
}
return 'tmpl_' + l + '_' + n
},
b: function (a, b) {
Expand Down Expand Up @@ -4476,6 +4482,9 @@ module.exports = {
}
l = depth
}
if (l === 15) {
return 'tmpl_15_container'
}
return 'tmpl_' + l + '_' + n
},
b: function (a, b) {
Expand Down Expand Up @@ -6023,6 +6032,9 @@ module.exports = {
}
l = depth
}
if (l === 15) {
return 'tmpl_15_container'
}
return 'tmpl_' + l + '_' + n
},
b: function (a, b) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1529,6 +1529,9 @@ module.exports = {
}
l = depth
}
if (l === 15) {
return 'tmpl_15_container'
}
return 'tmpl_' + l + '_' + n
},
b: function (a, b) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2742,6 +2742,9 @@ module.exports = {
}
l = depth
}
if (l === 15) {
return 'tmpl_15_container'
}
return 'tmpl_' + l + '_' + n
},
b: function (a, b) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1385,6 +1385,9 @@ module.exports = {
}
l = depth
}
if (l === 15) {
return 'tmpl_15_container'
}
return 'tmpl_' + l + '_' + n
},
b: function (a, b) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1367,6 +1367,9 @@ module.exports = {
}
l = depth
}
if (l === 15) {
return 'tmpl_15_container'
}
return 'tmpl_' + l + '_' + n
},
b: function (a, b) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1374,6 +1374,9 @@ module.exports = {
}
l = depth
}
if (l === 15) {
return 'tmpl_15_container'
}
return 'tmpl_' + l + '_' + n
},
b: function (a, b) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1656,6 +1656,9 @@ module.exports = {
}
l = depth
}
if (l === 15) {
return 'tmpl_15_container'
}
return 'tmpl_' + l + '_' + n
},
b: function (a, b) {
Expand Down
2 changes: 1 addition & 1 deletion packages/taro-mini-runner/src/plugins/MiniPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,7 @@ export default class TaroMiniPlugin {
}
}
if (isUsingCustomWrapper) {
baseCompConfig[customWrapperName] = `./${customWrapperName}`
baseCompConfig.usingComponents[customWrapperName] = `./${customWrapperName}`
this.generateConfigFile(compilation, this.getIsBuildPluginPath(customWrapperName, isBuildPlugin), {
component: true,
usingComponents: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1440,6 +1440,9 @@ module.exports = {
}
l = depth
}
if (l === 15) {
return 'tmpl_15_container'
}
return 'tmpl_' + l + '_' + n
},
b: function (a, b) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1435,6 +1435,9 @@ module.exports = {
}
l = depth
}
if (l === 15) {
return 'tmpl_15_container'
}
return 'tmpl_' + l + '_' + n
},
b: function (a, b) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1606,6 +1606,9 @@ module.exports = {
}
l = depth
}
if (l === 19) {
return 'tmpl_19_container'
}
return 'tmpl_' + l + '_' + n
},
b: function (a, b) {
Expand Down Expand Up @@ -3345,6 +3348,9 @@ module.exports = {
}
l = depth
}
if (l === 15) {
return 'tmpl_15_container'
}
return 'tmpl_' + l + '_' + n
},
b: function (a, b) {
Expand Down Expand Up @@ -5129,6 +5135,9 @@ module.exports = {
}
l = depth
}
if (l === 15) {
return 'tmpl_15_container'
}
return 'tmpl_' + l + '_' + n
},
b: function (a, b) {
Expand Down Expand Up @@ -6921,6 +6930,9 @@ module.exports = {
}
l = depth
}
if (l === 15) {
return 'tmpl_15_container'
}
return 'tmpl_' + l + '_' + n
},
b: function (a, b) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1457,6 +1457,9 @@ module.exports = {
}
l = depth
}
if (l === 15) {
return 'tmpl_15_container'
}
return 'tmpl_' + l + '_' + n
},
b: function (a, b) {
Expand Down Expand Up @@ -3247,6 +3250,9 @@ module.exports = {
}
l = depth
}
if (l === 15) {
return 'tmpl_15_container'
}
return 'tmpl_' + l + '_' + n
},
b: function (a, b) {
Expand Down
Loading

0 comments on commit 2dae08a

Please sign in to comment.