Skip to content

Commit

Permalink
Merge pull request #1318 from didi/fix_web_compile
Browse files Browse the repository at this point in the history
Fix web compile
  • Loading branch information
hiyuki authored Nov 10, 2023
2 parents f393ffc + a2dabae commit d3f067d
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ Mpx的核心设计思路为增强,不同于业内大部分小程序框架将we
核心团队: [hiyuki](https://github.com/hiyuki), [Blackgan3](https://github.com/Blackgan3), [anotherso1a](https://github.com/anotherso1a), [CommanderXL](https://github.com/CommanderXL), [yandadaFreedom](https://github.com/yandadaFreedom), [wangxiaokou](https://github.com/wangxiaokou), [OnlyProbie](https://github.com/OnlyProbie), [pagnkelly](https://github.com/pagnkelly), [thuman](https://github.com/thuman), [theniceangel](https://github.com/theniceangel), [dolymood](https://github.com/dolymood)
外部贡献者:[sky-admin](https://github.com/sky-admin), [pkingwa](https://github.com/pkingwa), [httpsxiao](https://github.com/httpsxiao), [lsycxyj](https://github.com/lsycxyj), [okxiaoliang4](https://github.com/okxiaoliang4), [tangminFE](https://github.com/tangminFE), [codepan](https://github.com/codepan), [zqjimlove](https://github.com/zqjimlove), [xuehebinglan](https://github.com/xuehebinglan), [wangxiaokou](https://github.com/wangxiaokou), [zhaoyiming0803](https://github.com/zhaoyiming0803), [ctxrr](https://github.com/ctxrr), [JanssenZhang](https://github.com/JanssenZhang), [heiye9](https://github.com/heiye9), [lj0812](https://github.com/lj0812), [SuperHuangXu](https://github.com/SuperHuangXu), [twtylkmrh](https://github.com/twtylkmrh), [NineSwordsMonster](https://github.com/NineSwordsMonster)
外部贡献者:[sky-admin](https://github.com/sky-admin), [pkingwa](https://github.com/pkingwa), [httpsxiao](https://github.com/httpsxiao), [lsycxyj](https://github.com/lsycxyj), [okxiaoliang4](https://github.com/okxiaoliang4), [tangminFE](https://github.com/tangminFE), [codepan](https://github.com/codepan), [zqjimlove](https://github.com/zqjimlove), [xuehebinglan](https://github.com/xuehebinglan), [zhaoyiming0803](https://github.com/zhaoyiming0803), [ctxrr](https://github.com/ctxrr), [JanssenZhang](https://github.com/JanssenZhang), [heiye9](https://github.com/heiye9), [lj0812](https://github.com/lj0812), [SuperHuangXu](https://github.com/SuperHuangXu), [twtylkmrh](https://github.com/twtylkmrh), [NineSwordsMonster](https://github.com/NineSwordsMonster)
## 成功案例
Expand Down
3 changes: 1 addition & 2 deletions packages/core/@types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -614,8 +614,7 @@ export function onTabItemTap (callback: WechatMiniprogram.Page.ILifetime['onTabI
export function onSaveExitState (callback: () => void): void

// get instance
export function getCurrentInstance<T extends ComponentIns<{}, {}, {}>> (): T

export function getCurrentInstance<T extends ComponentIns<{}, {}, {}>> (): { proxy: T, [x: string]: any }
// I18n
export function useI18n<Options extends {
inheritLocale?: boolean
Expand Down
6 changes: 3 additions & 3 deletions packages/webpack-plugin/lib/platform/json/wx/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const normalizeTest = require('../normalize-test')
const changeKey = require('../change-key')
const normalize = require('../../../utils/normalize')
const { capitalToHyphen } = require('../../../utils/string')
const { isOriginTag } = require('../../../utils/dom-tag-config')
const { isOriginTag, isBuildInTag } = require('../../../utils/dom-tag-config')

const mpxViewPath = normalize.lib('runtime/components/ali/mpx-view.mpx')
const mpxTextPath = normalize.lib('runtime/components/ali/mpx-text.mpx')
Expand Down Expand Up @@ -127,7 +127,7 @@ module.exports = function getSpec ({ warn, error }) {
}

/**
* 将小程序代码中使用的与原生 HTML tag 同名组件进行转化,以解决与原生tag命名冲突问题。
* 将小程序代码中使用的与原生 HTML tag 或 内建组件 同名的组件进行转化,以解决与原生tag命名冲突问题。
* @param {string} type usingComponents
* @returns input
*/
Expand All @@ -136,7 +136,7 @@ module.exports = function getSpec ({ warn, error }) {
const usingComponents = input[type]
if (usingComponents) {
Object.keys(usingComponents).forEach(tag => {
if (isOriginTag(tag)) {
if (isOriginTag(tag) || isBuildInTag(tag)) {
usingComponents[`mpx-com-${tag}`] = usingComponents[tag]
delete usingComponents[tag]
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const { isOriginTag } = require('../../../../utils/dom-tag-config')
const { isOriginTag, isBuildInTag } = require('../../../../utils/dom-tag-config')

module.exports = function () {
return {
waterfall: true,
test: (input) => isOriginTag(input),
test: (input) => isOriginTag(input) || isBuildInTag(input),
// 处理原生tag
web (tag, data = {}) {
// @see packages/webpack-plugin/lib/platform/json/wx/index.js webHTMLTagProcesser
Expand Down
14 changes: 14 additions & 0 deletions packages/webpack-plugin/lib/utils/dom-tag-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,19 @@ const isNativeMiniTag = makeMap(
'open-data,native-component,aria-component,page-meta'
)

/**
* 是否为mpx内置组件
* collected from packages/webpack-plugin/lib/runtime/components/web/
*/
const isBuildInTag = makeMap(
'mpx-image,mpx-picker-view,mpx-slider,mpx-textarea,mpx-input,mpx-picker,' +
'mpx-swiper-item,mpx-video,mpx-button,mpx-keep-alive,mpx-progress,' +
'mpx-swiper,mpx-view,mpx-checkbox-group,mpx-movable-area,mpx-radio-group,' +
'mpx-switch,mpx-web-view,mpx-checkbox,mpx-movable-view,mpx-radio,' +
'mpx-tab-bar-container,mpx-form,mpx-navigator,mpx-rich-text,mpx-tab-bar,' +
'mpx-icon,mpx-picker-view-column,mpx-scroll-view,mpx-text'
)

const isSpace = makeMap('ensp,emsp,nbsp')

const isContWidth = makeMap('col,colgroup,img,table,td,th,tr')
Expand All @@ -92,6 +105,7 @@ module.exports = {
isVoidTag,
isNonPhrasingTag,
isRichTextTag,
isBuildInTag,
isUnaryTag,
isSpace,
isContWidth,
Expand Down

0 comments on commit d3f067d

Please sign in to comment.