fix(desktop): resolve plugin-dialog wherever the package manager put it
`bun run desktop` dies before the window opens on a fresh clone:
Error: ENOENT: no such file or directory, open
'.../frontend/node_modules/@tauri-apps/plugin-dialog/dist-js/index.js'
The alias hardcoded `frontend/node_modules/...`, but this is a bun
workspace: bun hoists the package to the workspace root and leaves
`frontend/node_modules` empty, so the path the alias names does not
exist. Vite's dep optimizer reads it directly and throws, taking
`beforeDevCommand` — and the whole desktop shell — down with it.
Probe both layouts and fall through to Vite's own resolution when
neither is present, so a missing package degrades to normal resolution
instead of crashing the dev server.
Verified on macOS 26.6 (Apple Silicon), bun 1.2.22, fresh clone: the
window now opens and the backend serves.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
f2302e8c95
commit
847ca6d44c
@@ -10,6 +10,8 @@ the frozen-backend fallback mirror it for their toolchains.
|
||||
|
||||
**Highlights**
|
||||
|
||||
- The desktop app builds and opens from a fresh clone again (#1818)
|
||||
|
||||
### Changed
|
||||
|
||||
### Added
|
||||
@@ -18,6 +20,8 @@ the frozen-backend fallback mirror it for their toolchains.
|
||||
|
||||
### Fixed
|
||||
|
||||
- `bun run desktop` now opens on a fresh clone: the Vite alias for `@tauri-apps/plugin-dialog` no longer assumes a nested `frontend/node_modules`, which bun's workspace hoisting leaves empty (#1818)
|
||||
|
||||
|
||||
## [0.5.2] — 2026-09-02
|
||||
|
||||
|
||||
+11
-5
@@ -2,10 +2,15 @@ import { defineConfig } from 'vite';
|
||||
import react from '@vitejs/plugin-react';
|
||||
import tailwindcss from '@tailwindcss/vite';
|
||||
import path from 'path';
|
||||
import { readFileSync } from 'fs';
|
||||
import { readFileSync, existsSync } from 'fs';
|
||||
|
||||
const pkg = JSON.parse(readFileSync(path.resolve(__dirname, 'package.json'), 'utf-8'));
|
||||
|
||||
const dialogEsm = [
|
||||
path.resolve(__dirname, 'node_modules/@tauri-apps/plugin-dialog/dist-js/index.js'),
|
||||
path.resolve(__dirname, '../node_modules/@tauri-apps/plugin-dialog/dist-js/index.js'),
|
||||
].find(existsSync);
|
||||
|
||||
// https://vite.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [tailwindcss(), react()],
|
||||
@@ -20,10 +25,11 @@ export default defineConfig({
|
||||
// tsconfig.json `paths` so the type-checker agrees). Lets shadcn
|
||||
// primitives import `@/lib/utils` and `npx shadcn add` work unmodified.
|
||||
'@': path.resolve(__dirname, 'src'),
|
||||
'@tauri-apps/plugin-dialog': path.resolve(
|
||||
__dirname,
|
||||
'node_modules/@tauri-apps/plugin-dialog/dist-js/index.js',
|
||||
),
|
||||
// Package managers may install this nested (frontend/node_modules) or
|
||||
// hoisted to the workspace root; a hardcoded path breaks whichever
|
||||
// layout it did not guess. Probe both, and fall through to Vite's own
|
||||
// resolution when neither exists rather than crashing the optimizer.
|
||||
...(dialogEsm ? { '@tauri-apps/plugin-dialog': dialogEsm } : {}),
|
||||
},
|
||||
},
|
||||
server: {
|
||||
|
||||
Reference in New Issue
Block a user