Skip to content

Commit e992e72

Browse files
committed
fix(uts): dep编译时正确启用 cache 任务缓存
1 parent ee80148 commit e992e72

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

packages/uni-cli-shared/src/vite/plugins/uts/uni_modules.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -455,19 +455,20 @@ export function uniUTSAppUniModulesPlugin(
455455
if (deps.length) {
456456
for (const dep of deps) {
457457
if (dep) {
458-
// 本次编译流程中已编译过该插件,直接使用缓存
459458
const depPluginDir = normalizePath(path.resolve(uniModulesDir, dep))
459+
// 本次编译流程中已编译过该插件,直接使用缓存
460460
if (utsModuleCaches.get(depPluginDir)) {
461461
await utsModuleCaches.get(depPluginDir)!().then((result) => {
462462
if (result) {
463463
handleCompileResult(result, pluginContext)
464464
}
465465
})
466466
} else {
467-
await compilePlugin(
468-
path.resolve(inputDir, 'uni_modules', dep),
469-
pluginContext
470-
).then((result) => {
467+
const compile = once(() => {
468+
return compilePlugin(depPluginDir, pluginContext)
469+
})
470+
utsModuleCaches.set(depPluginDir, compile)
471+
await compile().then((result) => {
471472
if (result) {
472473
handleCompileResult(result, pluginContext)
473474
}

0 commit comments

Comments
 (0)