提交 759ca34b 编写于 作者: fxy060608's avatar fxy060608

wip(uts): 当使用本地内置组件及API时,不记录模块依赖

上级 4ff9200e
......@@ -294,7 +294,7 @@ export async function transformVue(
)
}
},
parseUTSComponent: parseUTSComponent,
parseUTSComponent,
})
templateCode = templateResult.code
templateImportEasyComponentsCode =
......@@ -303,7 +303,15 @@ export async function transformVue(
templateResult.importUTSComponents.join('\n')
templateSourceMap = templateResult.map
if (process.env.NODE_ENV === 'production') {
addExtApiComponents(templateResult.elements)
addExtApiComponents(
templateResult.elements.filter((element) => {
// 如果是UTS原生组件,则无需记录摇树
if (parseUTSComponent(element, 'kotlin')) {
return false
}
return true
})
)
}
}
// 生成 script 文件
......
......@@ -29,6 +29,7 @@ import {
} from '../utils'
import { KotlinManifestCache } from '../stacktrace/kotlin'
import { isWindows } from '../shared'
import { hasOwn } from '@vue/shared'
const DEFAULT_IMPORTS = [
'kotlinx.coroutines.async',
......@@ -364,20 +365,29 @@ async function runKotlinBuild(options: CompileAppOptions, result: UTSResult) {
;(result as RunKotlinBuildResult).type = 'kotlin'
;(result as RunKotlinBuildResult).inject_modules = parseInjectModules(
result.inject_apis || [],
options.extApis || {},
options.extApiComponents
)
;(result as RunKotlinBuildResult).kotlinc = false
return result as RunKotlinBuildResult
}
function parseInjectModules(inject_apis: string[], extApiComponents: string[]) {
function parseInjectModules(
inject_apis: string[],
localExtApis: Record<string, [string, string]>,
extApiComponents: string[]
) {
const modules = new Set<string>()
const extApiModules = parseExtApiModules()
inject_apis.forEach((api) => {
if (api.startsWith('uniCloud.')) {
modules.add('uni-cloud-client')
} else {
if (extApiModules[api]) {
if (
extApiModules[api] &&
// 非本地
!hasOwn(localExtApis, api.replace('uni.', ''))
) {
modules.add(extApiModules[api])
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册