Skip to content

Commit 78d6dcb

Browse files
committed
fix(bundler): copy the vite bundle to native in non-watch builds
The Vite bundler integration copies its output (`.ns-vite-build/`) into the native project's `assets/app` only from the watch-mode IPC handler in `compileWithWatch` (the `emittedFiles` message). A non-watch build — `ns build`, or `ns run --justlaunch` — runs `compileWithoutWatch`, which has no IPC channel (`startBundleProcess` sets `stdio: "inherit"` when `prepareData.watch` is false) and never calls `copyViteBundleToNative`. The Vite output is therefore left in `.ns-vite-build/`, `assets/app` stays empty, and the Static Binding Generator fails with "Couldn't find sbg-bindings.txt" (no JS input). Webpack/rspack are unaffected — they write directly into the platform folder. Copy the full Vite bundle in `compileWithoutWatch`'s `close` handler on a successful (exit code 0) build, mirroring the full-build branch of the watch-mode copy.
1 parent 69ac96d commit 78d6dcb

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,25 @@ export class BundlerCompilerService
380380
delete this.bundlerProcesses[platformData.platformNameLowerCase];
381381
const exitCode = typeof arg === "number" ? arg : arg && arg.code;
382382
if (exitCode === 0) {
383+
// In watch mode the Vite output is copied into the native
384+
// project from the `emittedFiles` IPC message. A non-watch
385+
// build (`ns build`, `ns run --justlaunch`) has no IPC
386+
// channel — `startBundleProcess` sets `stdio: "inherit"`
387+
// when `prepareData.watch` is false — so that copy never
388+
// runs and `<platform>/.../assets/app` stays empty, leaving
389+
// the Static Binding Generator with no input. Copy the full
390+
// Vite bundle here instead.
391+
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,
399+
);
400+
this.copyViteBundleToNative(distOutput, destDir);
401+
}
383402
resolve();
384403
} else {
385404
const error: any = new Error(

0 commit comments

Comments
 (0)