Skip to content

Commit 76778c7

Browse files
committed
refactor(bundler): extract getVitePaths helper
Share the .ns-vite-build / assets-app path computation between the watch-mode emittedFiles copy and the non-watch copy (CodeRabbit review).
1 parent 78d6dcb commit 76778c7

1 file changed

Lines changed: 21 additions & 14 deletions

File tree

lib/services/bundler/bundler-compiler-service.ts

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,9 @@ export class BundlerCompilerService
126126
}
127127

128128
// Copy Vite output files directly to platform destination
129-
const distOutput = path.join(
130-
projectData.projectDir,
131-
".ns-vite-build",
132-
);
133-
const destDir = path.join(
134-
platformData.appDestinationDirectoryPath,
135-
this.$options.hostProjectModuleName,
129+
const { distOutput, destDir } = this.getVitePaths(
130+
platformData,
131+
projectData,
136132
);
137133

138134
if (debugLog) {
@@ -389,13 +385,9 @@ export class BundlerCompilerService
389385
// the Static Binding Generator with no input. Copy the full
390386
// Vite bundle here instead.
391387
if (this.getBundler() === "vite") {
392-
const distOutput = path.join(
393-
projectData.projectDir,
394-
".ns-vite-build",
395-
);
396-
const destDir = path.join(
397-
platformData.appDestinationDirectoryPath,
398-
this.$options.hostProjectModuleName,
388+
const { distOutput, destDir } = this.getVitePaths(
389+
platformData,
390+
projectData,
399391
);
400392
this.copyViteBundleToNative(distOutput, destDir);
401393
}
@@ -864,6 +856,21 @@ export class BundlerCompilerService
864856
return this.$projectConfigService.getValue(`bundler`, "webpack");
865857
}
866858

859+
// The Vite output directory and its destination in the native project —
860+
// shared by the watch-mode `emittedFiles` copy and the non-watch copy.
861+
private getVitePaths(
862+
platformData: IPlatformData,
863+
projectData: IProjectData,
864+
): { distOutput: string; destDir: string } {
865+
return {
866+
distOutput: path.join(projectData.projectDir, ".ns-vite-build"),
867+
destDir: path.join(
868+
platformData.appDestinationDirectoryPath,
869+
this.$options.hostProjectModuleName,
870+
),
871+
};
872+
}
873+
867874
private copyViteBundleToNative(
868875
distOutput: string,
869876
destDir: string,

0 commit comments

Comments
 (0)