Skip to content

Commit 4dc9dc0

Browse files
authored
fix(scripts): launch vite through dev script on Windows (CoreBunch#193)
1 parent 10bb66b commit 4dc9dc0

3 files changed

Lines changed: 11 additions & 8 deletions

File tree

scripts/dev.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* - Pre-checks ports 3001 (cms) and 5173 (vite) and prints an
2222
* actionable message if either is held by something we don't own.
2323
* - Spawns the cms (`bun --watch server/index.ts`) and vite
24-
* (`bun run vite --host 127.0.0.1`) as children, forwarding their output
24+
* (`bun run dev:vite --host 127.0.0.1`) as children, forwarding their output
2525
* and signals so Ctrl+C cleanly kills both.
2626
*/
2727

@@ -252,7 +252,7 @@ const processes: DevProcess[] = [
252252
},
253253
{
254254
name: 'vite',
255-
command: bunRunCommand('vite', '--host', '127.0.0.1', '--port', String(VITE_PORT), '--strictPort'),
255+
command: bunRunCommand('dev:vite', '--host', '127.0.0.1', '--port', String(VITE_PORT), '--strictPort'),
256256
},
257257
]
258258

scripts/e2e-dev.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function stopChildren(signal: NodeJS.Signals = 'SIGTERM'): void {
4747

4848
for (const command of [
4949
bunCommand('server/index.ts'),
50-
bunRunCommand('vite', '--host', '127.0.0.1', '--port', VITE_PORT, '--strictPort'),
50+
bunRunCommand('dev:vite', '--host', '127.0.0.1', '--port', VITE_PORT, '--strictPort'),
5151
]) {
5252
const child = Bun.spawn(command, {
5353
env: sharedEnv,

src/__tests__/devWorkflow.test.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@ describe('development workflow', () => {
1717
expect(pkg.scripts['dev']).toBe('bun run scripts/dev.ts')
1818
expect(pkg.scripts['dev:agent']).toBe('bun run dev:server')
1919
expect(pkg.scripts['dev:server']).toBe('bun --watch server/index.ts')
20+
expect(pkg.scripts['dev:vite']).toBe('vite')
2021
expect(pkg.scripts['dev:all']).toBeUndefined()
2122
expect(existsSync(new URL('scripts/dev.ts', root))).toBe(true)
2223
expect(existsSync(new URL('scripts/dev-all.ts', root))).toBe(false)
2324

2425
const script = readSiteFile('scripts/dev.ts')
2526
// Spawns cms + vite without a recursive `bun run dev` call.
2627
expect(script).toContain("bunCommand('--watch', 'server/index.ts')")
27-
expect(script).toContain("bunRunCommand('vite', '--host', '127.0.0.1'")
28+
expect(script).toContain("bunRunCommand('dev:vite', '--host', '127.0.0.1'")
2829
expect(script).not.toContain('command: `vite')
2930
expect(script).not.toContain('command.split')
3031
// Knows about the docker postgres host port.
@@ -49,18 +50,20 @@ describe('development workflow', () => {
4950
'--watch',
5051
'server/index.ts',
5152
])
52-
expect(bunRunCommand('vite', '--host', '127.0.0.1')).toEqual([
53+
expect(bunRunCommand('dev:vite', '--host', '127.0.0.1')).toEqual([
5354
process.execPath,
5455
'run',
55-
'vite',
56+
'dev:vite',
5657
'--host',
5758
'127.0.0.1',
5859
])
5960

60-
expect(devScript).toContain("bunRunCommand('vite', '--host', '127.0.0.1'")
61+
expect(devScript).toContain("bunRunCommand('dev:vite', '--host', '127.0.0.1'")
62+
expect(devScript).not.toContain("bunRunCommand('vite'")
6163
expect(devScript).not.toContain('command: `vite')
6264
expect(devScript).not.toContain('command.split')
63-
expect(e2eScript).toContain("bunRunCommand('vite', '--host', '127.0.0.1'")
65+
expect(e2eScript).toContain("bunRunCommand('dev:vite', '--host', '127.0.0.1'")
66+
expect(e2eScript).not.toContain("bunRunCommand('vite'")
6467
expect(e2eScript).not.toContain("['vite'")
6568
expect(e2eScript).not.toContain("['bun'")
6669
expect(startScript).toContain("bunRunCommand('build')")

0 commit comments

Comments
 (0)