Skip to content

fix(scripts): launch vite through entrypoint on Windows#202

Merged
DavidBabinec merged 1 commit into
mainfrom
fix/windows-vite-entrypoint
Jul 8, 2026
Merged

fix(scripts): launch vite through entrypoint on Windows#202
DavidBabinec merged 1 commit into
mainfrom
fix/windows-vite-entrypoint

Conversation

@DavidBabinec

Copy link
Copy Markdown
Contributor

What changed

  • Add viteCommand(...), which runs Vite by calling the current Bun executable with node_modules/vite/bin/vite.js directly.
  • Switch scripts/dev.ts and scripts/e2e-dev.ts from bun run dev:vite to viteCommand(...).
  • Add scripts/vite.ts as the package-script wrapper for Vite commands.
  • Change dev:vite, build, and preview so package scripts no longer invoke bare vite.
  • Extend devWorkflow.test.ts to assert the direct Vite entrypoint path and reject bunRunCommand('dev:vite') / bare vite launcher regressions.

Why

PR #193 fixed direct Windows uv_spawn failures, but the follow-up user report showed another lookup layer still failing:

$ vite --host "127.0.0.1" --port "5173" --strictPort
bun: command not found: vite
error: script "dev:vite" exited with code 1

That means bun run dev:vite still asks Bun's package-script runner to resolve the bare vite command on that Windows setup. This PR removes that lookup path entirely for bun run dev: the child process is now process.execPath plus Vite's JS entrypoint path.

Verification

  • Red-green regression: bun test src/__tests__/devWorkflow.test.ts failed before the helper/wrapper existed, then passed after the fix.
  • bun -e "import { viteCommand } from './scripts/lib/bunCommand.ts'; const r = Bun.spawnSync(viteCommand('--version'), { stdout: 'pipe', stderr: 'pipe' }); console.log('exit', r.exitCode); console.log(r.stdout.toString().trim()); console.error(r.stderr.toString().trim()); process.exit(r.exitCode ?? 1);"
  • bun run scripts/vite.ts --version
  • bun run dev:vite --version
  • bun run build
  • bun run lint
  • bun test6024 pass, 0 fail
  • PORT=3091 VITE_PORT=5191 bun run dev smoke: CMS listened on 3091, Vite reported ready on 5191, no command not found, Script not found, uv_spawn, or ENOENT output.

import { describe, expect, it } from 'bun:test'
import { existsSync, readFileSync } from 'node:fs'
import { bunCommand, bunRunCommand } from '../../scripts/lib/bunCommand'
import { bunCommand, bunRunCommand, viteCommand } from '../../scripts/lib/bunCommand'
@DavidBabinec
DavidBabinec force-pushed the fix/windows-vite-entrypoint branch from d15376e to 880cfb3 Compare July 8, 2026 18:57
@DavidBabinec
DavidBabinec marked this pull request as ready for review July 8, 2026 19:23
@DavidBabinec
DavidBabinec merged commit fdfcb15 into main Jul 8, 2026
11 of 12 checks passed
lauer3912 pushed a commit to ClawCopilot/Instatic that referenced this pull request Jul 20, 2026
# Conflicts:
#	scripts/dev.ts
#	scripts/e2e-dev.ts
#	scripts/lib/bunCommand.ts
#	scripts/start.ts
#	src/__tests__/devWorkflow.test.ts
lauer3912 pushed a commit to ClawCopilot/Instatic that referenced this pull request Jul 20, 2026
Cherry-picked 15 upstream commits across 5 phases:

Phase 1 — Security:
  - ae7ed0d: CSP base-uri + object-src (CoreBunch#158)
  - c0087ec: XSS scheme-check htmlAttributes (CoreBunch#155)

Phase 2 — Windows compatibility:
  - 75086cf: Windows port probing (CoreBunch#170)
  - fdfcb15: vite through entrypoint (CoreBunch#202)
  - 8c957fe: Windows-safe slot symlink swap (CoreBunch#187)

Phase 3 — Editor fixes (7 commits):
  - Font weights, malformed fonts tolerance, empty container,
    canvas pan, layer icons, explorer tabs, responsive nav

Phase 4 — CMS core:
  - 43abba0: Transactional site-document save (43 files)
  - 61fcebc: Stop forcing table kind 'data' (CoreBunch#216)
  - 3a4a6fc: Custom data-table fields editing (CoreBunch#182)

Phase 5 — Other:
  - f139d3c: YouTube iframe routing (CoreBunch#151)
  - 6447a65: JSON-import media validation (CoreBunch#154)
  - 9a3af2d: Publisher media background optimization
  - 081e0d3: Collapse data.rows SQL query (CoreBunch#159)

Additional workspace fixes:
  - Migration 020 conflict resolved (renumbered to 021)
  - staticArtefact.ts: Windows plain-file slot swap
  - 15 test files: EBUSY-safe cleanup on Windows
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.

1 participant