feat: add vite support#14398
Conversation
- Fix command injection via exec() in simulator-launcher (use execFile)
- Fix silent device detection failure in device-installer
- Extract shared Vite helpers into cli/lib/vite-utils.js
- Replace promisify with manual wrapper for CLI callback convention
- Close Vite dev server on error, log errors before finishing
- Make metadata write failure non-fatal
- Distinguish ENOENT from other errors in readServeMetadata
- Handle non-Error truthy values in invokeLauncherStep
- Add port conflict guidance in start-server
- Initialize tiSymbols as {} to match object consumption pattern
- Extract DEFAULT_PORT constant, simplify port callback
|
Neat! I need some time to review. :) |
|
@janvennemann So this one needs to be reviewed, the titanium-vite packages need to be published and we'll need some docs / a guide? More? |
Yeah, that's roughly it, and the updated https://github.com/tidev/alloy-devkit packages also need to be published. I'd also mark this as a new experimental feature as I will surely need to flesh out a few additional thing with the Vite build. Especially the new dev workflow / liveview replacement that is the |
|
Sounds good. Please make sure to mark as review / assign reviewers once ready. Would like to have this out for broader testing in the next Ti SDK update (end of May if doable) |
Summary
I'm opening this as a draft for now since this involves changes across multiple other projects that need to be released first.
ti servecommand that starts a Vite dev server and launches the app, enabling HMR-based developmentbuildandservecommandsChanges
New
ti servecommand (cli/commands/serve.js)Orchestrates the Vite dev server lifecycle: starts the server, runs a build (or skips it if artifacts are fresh), then launches the app on the target platform using the extracted launchers.
Vite build hook (
cli/hooks/vite.js)Mirrors the existing Webpack hook pattern. Detects Vite in project dependencies, sets
builder.useBundler = true, and runs a one-shot Vite build duringbuild.pre.compile(skipped duringservesince the dev server is already running).Shared Vite utilities (
cli/lib/vite-utils.js)Resolves the project-local Vite installation, finds config files, and provides the
tiBridgePlugin/createTiViteBridgehelpers used by both the build hook and serve command.Serve helpers (
cli/lib/serve/)start-server.js— bootstraps the Vite dev server with HMR configurationmetadata.js— content-hash based staleness check for build artifact reuseresolve-host.js— picks the first non-internal IPv4 address for the dev serverPlatform launcher extraction
android/cli/lib/launcher.js— extracted fromandroid/cli/hooks/run.jsiphone/cli/lib/device-installer.js— extracted fromiphone/cli/hooks/install.jsiphone/cli/lib/simulator-launcher.js— extracted fromiphone/cli/hooks/run.jsexec→execFile)Build command updates
useWebpack→useBundleracross Android/iOS build commands andProcessJsTaskbuilderinstance from both platform_build.jsfiles soservecan access builder state