Skip to content

Commit

Permalink
feat(harmony): 模板内置独立模块har包
Browse files Browse the repository at this point in the history
  • Loading branch information
Wangyaqi committed Jan 6, 2025
1 parent 5ca5115 commit 61957de
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions packages/uni-app-harmony/src/compiler/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ function generateHarmonyImportSpecifier(id: string) {
})
}

function generateHarName(moduleName: string) {
return moduleName.replace(/@/g, '').replace(/\//g, '__').replace(/-/g, '_')
}

function generateHarmonyImportExternalCode(harmonyPackageNames: string[]) {
return harmonyPackageNames
.filter((harmonyPackageName) => isHarmonyGlobal(harmonyPackageName))
Expand Down Expand Up @@ -384,15 +388,14 @@ function initUniExtApi() {
const depPath = './uni_modules/' + dep.plugin
dependencies[dep.moduleSpecifier] = depPath
modules.push({
name: dep.moduleSpecifier
.replace(/@/g, '')
.replace(/\//g, '__')
.replace(/-/g, '_'),
name: generateHarName(dep.moduleSpecifier),
srcPath: depPath,
})
} else {
if (!dependencies[dep.moduleSpecifier]) {
dependencies[dep.moduleSpecifier] = dep.version!
dependencies[dep.moduleSpecifier] = `./libs/${generateHarName(
dep.moduleSpecifier
)}.har`
}
}
})
Expand Down

0 comments on commit 61957de

Please sign in to comment.