Skip to content

fix: copy Vite output for production builds#6083

Merged
NathanWalker merged 1 commit into
NativeScript:feat/vite-bundler-improvementsfrom
tannerlinsley:taren/copy-vite-production-bundle
Jul 22, 2026
Merged

fix: copy Vite output for production builds#6083
NathanWalker merged 1 commit into
NativeScript:feat/vite-bundler-improvementsfrom
tannerlinsley:taren/copy-vite-production-bundle

Conversation

@tannerlinsley

@tannerlinsley tannerlinsley commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Problem

Vite writes non-watch builds to .ns-vite-build, but the CLI only copied that output into the native app directory from the watch-mode IPC handler. ns build ios and ns build android could therefore package stale or missing JavaScript.

Fix

  • share Vite source/destination path resolution between watch and non-watch builds
  • copy a successful non-watch Vite build before resolving preparation
  • fail the production build when the Vite output is missing or cannot be copied
  • verify the source exists before replacing the destination

Validation

  • npm test (1509 passing, 9 pending)
  • release iOS simulator build; verified a unique production endpoint in the final .app bundle
  • signed Android release build; verified a unique production endpoint in the final .apk bundle

Summary by CodeRabbit

  • Bug Fixes

    • Vite builds now copy generated files to the native app destination immediately after successful non-watch builds.
    • Improved handling of missing or failed Vite output copies, with errors surfaced when required.
    • Destination directories are fully refreshed during Vite bundle copies to prevent stale files.
  • Tests

    • Added coverage for successful Vite output copying and copy failure handling.

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Vite build paths are centralized, native output copying now supports fail-fast behavior, and non-watch compilation copies successful Vite builds before resolving. Tests cover successful copying and propagation of copy failures.

Changes

Vite bundle copy reliability

Layer / File(s) Summary
Vite paths and copy errors
lib/services/bundler/bundler-compiler-service.ts
Vite output and native destination paths use a shared helper; full-build copying validates output, recreates destinations, and conditionally rethrows errors.
Non-watch Vite completion
lib/services/bundler/bundler-compiler-service.ts, test/services/bundler/bundler-compiler-service.ts
Successful Vite compilation copies output with fail-fast handling before resolving, while tests cover successful copying and rejected compilation.
Estimated code review effort: 3 (Moderate) ~20 minutes

Poem

I’m a rabbit with bundles tucked neat,
Vite hops from its build to the street.
Paths now know where to go,
Errors clearly say “no,”
And native apps get a copy so sweet!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: copying Vite output for production builds.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@NathanWalker

Copy link
Copy Markdown
Contributor

Thanks @tannerlinsley we have a lot of Vite improvements targeting 9.1 - this case is handled here:
https://github.com/NativeScript/nativescript-cli/pull/6010/changes#diff-8521a4dbe0da9ef2aed7d98bcabac41a7465f50c76019e2b539c9d214c4bf310
However you address a failure mode that's better so I'll bring both together soon.

You can use this (which includes 6010) now, with npm i -g nativescript@alpha and if using npm scripts can ensure it picks up a local scoped cli if needed npm i --save-dev nativescript@alpha

@NathanWalker NathanWalker self-assigned this Jul 21, 2026
@NathanWalker NathanWalker added this to the 9.1 milestone Jul 21, 2026
@NathanWalker
NathanWalker changed the base branch from main to feat/vite-bundler-improvements July 21, 2026 20:45
@NathanWalker

Copy link
Copy Markdown
Contributor

Ignore the merge conflicts, I'll handle those later today or tomorrow 👍

@NathanWalker
NathanWalker merged commit 119042b into NativeScript:feat/vite-bundler-improvements Jul 22, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants