99 BUNDLER_COMPILATION_COMPLETE ,
1010 PackageManagers ,
1111 CONFIG_FILE_NAME_DISPLAY ,
12+ VITE_DIST_FOLDER_NAME ,
1213} from "../../constants" ;
1314import {
1415 IPackageManager ,
@@ -128,7 +129,7 @@ export class BundlerCompilerService
128129 // Copy Vite output files directly to platform destination
129130 const distOutput = path . join (
130131 projectData . projectDir ,
131- ".ns-vite-build" ,
132+ VITE_DIST_FOLDER_NAME ,
132133 ) ;
133134 const destDir = path . join (
134135 platformData . appDestinationDirectoryPath ,
@@ -373,6 +374,8 @@ export class BundlerCompilerService
373374 reject ( err ) ;
374375 } ) ;
375376
377+ const isVite = this . getBundler ( ) === "vite" ;
378+
376379 childProcess . on ( "close" , async ( arg : any ) => {
377380 await this . $cleanupService . removeKillProcess (
378381 childProcess . pid . toString ( ) ,
@@ -381,6 +384,34 @@ export class BundlerCompilerService
381384 delete this . bundlerProcesses [ platformData . platformNameLowerCase ] ;
382385 const exitCode = typeof arg === "number" ? arg : arg && arg . code ;
383386 if ( exitCode === 0 ) {
387+ // Non-watch Vite builds spawn the child with stdio:"inherit"
388+ // (no IPC channel), so the emittedFiles message handler in
389+ // compileWithWatch never fires and the Vite output is never
390+ // copied to the platforms app folder. Mirror that copy step
391+ // here so release/CI prepare and build flows actually deploy
392+ // the freshly built bundle. Without this, the deploy folder
393+ // is left empty (or worse, runs stale dev/HMR artifacts from
394+ // a previous `ns debug` run) and the runtime crashes on
395+ // launch with `Check failed: has_pending_exception()`.
396+ if ( isVite ) {
397+ try {
398+ const distOutput = path . join (
399+ projectData . projectDir ,
400+ VITE_DIST_FOLDER_NAME ,
401+ ) ;
402+ const destDir = path . join (
403+ platformData . appDestinationDirectoryPath ,
404+ this . $options . hostProjectModuleName ,
405+ ) ;
406+ this . copyViteBundleToNative ( distOutput , destDir ) ;
407+ } catch ( copyErr ) {
408+ this . $logger . warn (
409+ `Failed to copy Vite output to platform destination: ${
410+ ( copyErr as Error ) . message
411+ } `,
412+ ) ;
413+ }
414+ }
384415 resolve ( ) ;
385416 } else {
386417 const error : any = new Error (
0 commit comments