()
| 55 | }, |
| 56 | // Defer CLI notification until after all plugins (including static copy) are done. |
| 57 | closeBundle() { |
| 58 | if (opts.hmrActive && !isInitialBuild) { |
| 59 | // Reset trackers to avoid leaking state between builds even if no-op |
| 60 | lastBundleFiles.clear(); |
| 61 | lastOutDir = undefined; |
| 62 | return; |
| 63 | } |
| 64 | if (!opts.isDevMode) return; |
| 65 | |
| 66 | const buildType = isInitialBuild ? 'initial' : 'incremental'; |
| 67 | if (opts.verbose) { |
| 68 | console.log(`NativeScript: ${buildType} build completed.`); |
| 69 | } |
| 70 | |
| 71 | // Determine outDir and ensure it exists in dev for a clean start |
| 72 | const distDir = (lastOutDir as string) || opts.distOutputFolder; |
| 73 | if (!existsSync(distDir)) { |
| 74 | try { |
| 75 | mkdirSync(distDir, { recursive: true }); |
| 76 | } catch { |
| 77 | // ignore; listing will just return [] |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | // Prefer Rollup-reported bundle files; fall back to FS scan |
| 82 | const emittedFiles = lastBundleFiles.size ? Array.from(lastBundleFiles) : listFilesFlat(distDir); |
| 83 | if (opts.verbose) { |
| 84 | console.log(`[cliPlugin] closeBundle: distDir=${distDir}, captured=${lastBundleFiles.size}, fsScan=${emittedFiles.length}`); |
| 85 | } |
| 86 | |
| 87 | if (opts.verbose) { |
| 88 | console.log(`Emitted ${emittedFiles.length} files in ${buildType} build.`); |
| 89 | } |
| 90 | |
| 91 | if (process.send) { |
| 92 | const sendMessage = (files: string[]) => { |
| 93 | const message = { |
| 94 | emittedFiles: files, |
| 95 | chunkFiles: files.filter((f) => f.includes('chunk') || f.includes('vendor')), |
| 96 | hash: Date.now().toString(), |
| 97 | isHMR: false, |
| 98 | buildType, |
| 99 | timestamp: Date.now(), |
| 100 | } as const; |
| 101 | if (opts.verbose) { |
| 102 | console.log(`Sending ${buildType} build notification to CLI.`); |
| 103 | } |
| 104 | process.send(message as any); |
| 105 | }; |
| 106 | if (emittedFiles.length === 0) { |
| 107 | // Allow a short delay for any late FS writes by other post plugins |
| 108 | setTimeout(() => { |
| 109 | const rescanned = listFilesFlat(distDir); |
| 110 | if (opts.verbose) { |
| 111 | console.log(`[cliPlugin] delayed rescan found ${rescanned.length} files in ${distDir}`); |
| 112 | } |
| 113 | sendMessage(rescanned); |
| 114 | }, 50); |
nothing calls this directly
no test coverage detected