Title: feat(vite): single-process HMR dev and debug cleartext for Android by edusperoni · Pull Request #6209 · NativeScript/nativescript-cli · GitHub
Open Graph Title: feat(vite): single-process HMR dev and debug cleartext for Android by edusperoni · Pull Request #6209 · NativeScript/nativescript-cli
X Title: feat(vite): single-process HMR dev and debug cleartext for Android by edusperoni · Pull Request #6209 · NativeScript/nativescript-cli
Description: PR Checklist The PR title follows our guidelines: https://github.com/NativeScript/NativeScript/blob/master/tools/notes/CONTRIBUTING.md#commit-messages. There is an issue for the bug/feature this PR is for. To avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it. You have signed the CLA. All existing tests are passing: https://github.com/NativeScript/nativescript-cli/blob/master/CONTRIBUTING.md#contribute-to-the-code-base Tests for the changes are included. Stacked on #6208 (feat/vite-restart-ipc); review that one first. Pairs with NativeScript/NativeScript#11650 (the @nativescript/vite side). What is the current behavior? A Vite HMR session runs two Vite processes per platform: vite serve for HMR and vite build --watch to produce bundle.mjs, package.json and the app's static files that the CLI copies into the native project. On Android, a Vite HMR app loads its code from the dev server (127.0.0.1 through adb reverse) over plain HTTP. Android blocks cleartext HTTP by default since API 28, so the app cannot reach the dev server unless the project opts in by hand. What is the new behavior? Single-process HMR dev (iOS / visionOS) When the installed @nativescript/vite lists the platform under nativescriptCli.singleProcessDev in its package.json, the CLI spawns only vite serve with NS_VITE_SINGLE_PROCESS=1 and does not start the vite build --watch child. The dev server writes bundle.mjs, package.json and the app's static files into the staging directory itself and sends the same build messages vite build --watch sends today. The CLI takes those messages from the vite serve child, copies and syncs on them as before, and launches the app on the first one. One Vite process instead of two. A build message may now carry an optional removedFiles list, which the CLI deletes from the native app folder (assets removed during a session). The serve process is tracked as the platform's bundler process; a serve exit before its first message fails the run, and stopping the session terminates it once. The capability is a handshake: a package without the field keeps the two-process session, and an older CLI never sets NS_VITE_SINGLE_PROCESS, so the package keeps its two-process behavior. Every old/new package + CLI combination stays on a working path. NS_VITE_SINGLE_PROCESS=0 in the CLI's environment opts out. Debug-only cleartext for Android Vite HMR runs For a debug build with HMR on and the Vite bundler, native prepare writes a debug source set manifest (platforms/android/app/src/debug/AndroidManifest.xml) with android:usesCleartextTraffic="true" (and tools:replace for it). An app that ships its own debug manifest in App_Resources gets the attribute added to the copied file instead. App_Resources is never modified. Any other prepare (release, --no-hmr, another bundler) removes the file the CLI wrote, and the change check compares the wanted state with the native project so switching modes rebuilds the app. Because it lives in the debug source set, the attribute never reaches release builds. An app's own networkSecurityConfig takes precedence over the attribute and has to allow the dev host itself. Host projects (hostProjectPath) are skipped: native prepare doesn't write the manifest there, so the change check must not compare it. Verification iOS simulator, Vue and Angular apps in single-process mode: boot, edits, boot-error card, server-down fallback, and assets added / changed / removed. Compatibility matrix: new / old @nativescript/vite × new / old CLI, each combination takes a working path (single-process only when both sides are new). Android emulator API 35: debug HMR run reaches the dev server with cleartext enabled; a release build has no usesCleartextTraffic in its merged manifest (checked with aapt2). CLI unit suite: 2179 tests passing, including new specs for the single-process session and the cleartext manifest. Stacked on #6208. Pairs with NativeScript/NativeScript#11650.
Open Graph Description: PR Checklist The PR title follows our guidelines: https://github.com/NativeScript/NativeScript/blob/master/tools/notes/CONTRIBUTING.md#commit-messages. There is an issue for the bug/feature this...
X Description: PR Checklist The PR title follows our guidelines: https://github.com/NativeScript/NativeScript/blob/master/tools/notes/CONTRIBUTING.md#commit-messages. There is an issue for the bug/feature this...
Opengraph URL: https://github.com/NativeScript/nativescript-cli/pull/6209
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:cb2cab1b-e4dc-07e7-0541-ff59a4c3381e |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | E378:20AA01:19A30B5:2097241:6B0133BB |
| html-safe-nonce | 0f9629edbd1b71b3018a3bfaf6360e4f3e979311b0a843d7bafc1566ff53c39e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMzc4OjIwQUEwMToxOUEzMEI1OjIwOTcyNDE6NkIwMTMzQkIiLCJ2aXNpdG9yX2lkIjoiNzk5NDAzNTYxNDA3OTA3MTE2NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | b95ca750ba3bce9e51512b680e2076cd6578f765f0df0b5d77afbf44f5b0eff8 |
| hovercard-subject-tag | pull_request:5413955728 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/NativeScript/nativescript-cli/pull/6209/files |
| twitter:image | https://avatars.githubusercontent.com/u/4061767?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/4061767?s=400&v=4 |
| og:image:alt | PR Checklist The PR title follows our guidelines: https://github.com/NativeScript/NativeScript/blob/master/tools/notes/CONTRIBUTING.md#commit-messages. There is an issue for the bug/feature this... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/NativeScript/nativescript-cli git https://github.com/NativeScript/nativescript-cli.git |
| octolytics-dimension-user_id | 7392261 |
| octolytics-dimension-user_login | NativeScript |
| octolytics-dimension-repository_id | 21347346 |
| octolytics-dimension-repository_nwo | NativeScript/nativescript-cli |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 21347346 |
| octolytics-dimension-repository_network_root_nwo | NativeScript/nativescript-cli |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width