-
Notifications
You must be signed in to change notification settings - Fork 392
web支持asyncsubpackagerules构建配置,修复asyncsubpackagerules指定组件名与组件用已声明组件冲突问题 #2139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
2b1673e to
7e8a320
Compare
| if (placeholderEntry && !jsonObj.usingComponents[placeholder]) jsonObj.usingComponents[placeholder] = placeholderEntry | ||
| if (placeholderEntry) { | ||
| if (jsonObj.usingComponents[placeholder]) { | ||
| // TODO 如果存在placeholder与已有usingComponents冲突, 重新生成一个组件名,在当前组件后增加一个数字 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果当前usingComponents中的组件就是规则中配置的组件呢,不就重复注册了?
| } = createJSONHelper({ | ||
| loaderContext, | ||
| componentsMap, | ||
| localComponentsMap, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
入参希望稳定,看是否能够以注册回调的形式处理不同平台的处理差异
| tarRoot, | ||
| placeholder, | ||
| resourcePath, | ||
| resolveResourcePath, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
可以直接用resourcePath吧,这个resource是带query的
| return placeholder | ||
| } | ||
|
|
||
| const processAsyncSubpackageRules = (jsonObj, context, { name, tarRoot, placeholder, relativePath, resolveResourcePathMap }, callback) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename to processPlaceholder
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jsonObj, context, { name, tarRoot, placeholder, relativePath, resolveResourcePathMap }这些参数都合成到一个对象参数中吧
| }) | ||
| } | ||
|
|
||
| const fillInComponentPlaceholder = (jsonObj, { name: componentName, placeholder, placeholderEntry, resolveResourcePathMap }, callback) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
除callback的参数合成到一个对象参数中
| // 处理 驼峰转连字符 | ||
| input = componentNameCapitalToHyphen('componentPlaceholder')(input) | ||
| // 将 placeholder 中使用的内建组件转化为 mpx-xxx, 并在 usingComponents 填充 | ||
| function fixBuildComponentPlaceholder (input, { mode }) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename to fixComponentPlaceholder
|
|
||
| const processComponents = (components, context, callback) => { | ||
| if (components) { | ||
| const asyncComponents = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
外层可以包一个waterfall处理串行流程,优雅一些,不然好多callback处理
| pageConfig: ${JSON.stringify(pageConfig)}, | ||
| // @ts-ignore | ||
| componentsMap: ${shallowStringify(componentsMap)}, | ||
| componentsMap: componentsMap, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
为啥改动
| }) | ||
| }, | ||
| ({ asyncComponents, resolveResourcePathMap }, callback) => { | ||
| async.each(asyncComponents, ({ name, tarRoot, placeholder, relativePath }, callback) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
额,如果只有这么点逻辑的话要不还是改回去放回调里吧
feat1: web下支持asyncsubpackagerules配置注入placeholder
feat2: react下placeholder使用内置组件时在usingComponents中注入使用到的内置组件,逻辑与wx保持一致
fix1: 修复asyncsubpackagerules中声明的组件名与当前组件中usingComponents已声明组件名冲突时,asyncsubpackagerules无法生效问题
如下:compA的placeholder会被替换为bbb组件,但预期是aaa
修复后对于冲突的组件名将会在asyncsubpackagerules注入的组件名后加上数字,如下
fix2: 支付宝下asyncsubpackagerules中声明的组件名将会由驼峰转化为破折号