-
Notifications
You must be signed in to change notification settings - Fork 376
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
Feat support native to h5 #1410
base: master
Are you sure you want to change the base?
Conversation
# Conflicts: # packages/webpack-plugin/lib/index.js # packages/webpack-plugin/lib/json-compiler/helper.js # packages/webpack-plugin/lib/native-loader.js # packages/webpack-plugin/lib/platform/template/wx/index.js # packages/webpack-plugin/lib/web/processScript.js
}) | ||
}, | ||
methods: { | ||
setData (data, 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.
通过Vue.prototype来挂载
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.
移到VuePlugin.js当中
packages/webpack-plugin/lib/index.js
Outdated
@@ -1621,6 +1623,14 @@ try { | |||
}) | |||
} | |||
} | |||
if (queryObj.isNative && nativeLoaderIndex !== loaders.length - 1) { |
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.
需要考虑.ts的情况
if (mode === 'web') { | ||
resource = `${resource}?isNative=true` | ||
} else { | ||
resource = `!!${nativeLoaderPath}!${resource}?isNative=true` |
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.
统一在afterResolve中插入nativeLoader吧,这里统一加isNative Query就可以
@@ -201,6 +239,76 @@ module.exports = function (content) { | |||
if (json.componentPlaceholder) { | |||
componentPlaceholder = componentPlaceholder.concat(Object.values(json.componentPlaceholder)) | |||
} | |||
|
|||
if (mode === 'web') { |
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.
这块不会是copy的吧,抽一个通用逻辑呗
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.
vueContentCache的逻辑补齐
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.
mainScript逻辑补齐
@@ -140,6 +148,36 @@ module.exports = function (content) { | |||
}) | |||
}, callback) | |||
}, | |||
(callback) => { | |||
if (mode === 'web') { |
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.
只有template和json需要预读,且文件的支持类型需要保持一致
@@ -7,7 +7,8 @@ module.exports = function (content) { | |||
this.cacheable() | |||
// 兼容处理处理ts-loader中watch-run/updateFile逻辑,直接跳过当前loader及后续的loader返回内容 | |||
const pathExtname = path.extname(this.resourcePath) | |||
if (!['.vue', '.mpx'].includes(pathExtname)) { | |||
const { queryObj } = parseRequest(this.resource) |
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.
这块不可能经过selector的
return | ||
} | ||
Object.keys(data).forEach(key => { | ||
this[key] = data[key] |
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.
需要支持路径设置
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.
需要调用forceUpdate
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.
需要考虑key不在原有data中的情况
功能
支持原生组件跨平台输出H5
待补充