Skip to content

Commit af895ea

Browse files
korbinian90claude
andcommitted
fix(build): make manualChunks a function and raise macOS target for Vite 8
Vite 8 bundles with Rolldown, which rejects an object-form manualChunks ("Expected Function but received Object") and broke the PWA and Tauri builds. Convert both to the function form. Rolldown's worker bundler (esbuild) also cannot lower the inlined dcm2niix worker to the safari14 target, so bump the macOS/WebKit floor to safari15 (macOS 12+ ships Safari 15+). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 46d6ea7 commit af895ea

2 files changed

Lines changed: 15 additions & 7 deletions

File tree

apps/desktop-tauri/vite.config.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,10 @@ export default defineConfig({
8787
build: {
8888
outDir: 'build',
8989
sourcemap: true,
90-
// Tauri uses Chromium on Windows/Linux and WebKit on macOS
91-
target: process.env.TAURI_PLATFORM === 'windows' ? 'chrome105' : 'safari14',
90+
// Tauri uses Chromium on Windows/Linux and WebKit on macOS.
91+
// safari15 is the floor: Vite 8's worker bundler (esbuild) cannot lower
92+
// the inlined dcm2niix worker to safari14, and macOS 12+ ships Safari 15+.
93+
target: process.env.TAURI_PLATFORM === 'windows' ? 'chrome105' : 'safari15',
9294
// Don't minify for debug builds
9395
minify: !process.env.TAURI_DEBUG ? 'esbuild' : false,
9496
chunkSizeWarningLimit: 1000,
@@ -97,8 +99,11 @@ export default defineConfig({
9799
entryFileNames: 'assets/[name]-[hash].js',
98100
chunkFileNames: 'assets/[name]-[hash].js',
99101
assetFileNames: 'assets/[name]-[hash].[ext]',
100-
manualChunks: {
101-
vendor: ['preact', '@preact/signals'],
102+
// Rolldown (Vite 8) requires manualChunks to be a function, not an object
103+
manualChunks: (id) => {
104+
if (id.includes('/preact/') || id.includes('/@preact/signals')) {
105+
return 'vendor'
106+
}
102107
},
103108
},
104109
onwarn: (warning, warn) => {

apps/pwa/vite.config.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const gitRepoUrl = getGitRepoUrl()
3131
const isProd = process.env.NODE_ENV === 'production'
3232
// Support PR previews with PR_NUMBER environment variable
3333
const prNumber = process.env.PR_NUMBER
34-
const baseUrl = isProd
34+
const baseUrl = isProd
3535
? (prNumber ? `/niivue-vscode/pr-${prNumber}/` : '/niivue-vscode/')
3636
: '/'
3737

@@ -212,8 +212,11 @@ export default defineConfig({
212212
entryFileNames: 'assets/[name]-[hash].js',
213213
chunkFileNames: 'assets/[name]-[hash].js',
214214
assetFileNames: 'assets/[name]-[hash].[ext]',
215-
manualChunks: {
216-
vendor: ['preact', '@preact/signals'],
215+
// Rolldown (Vite 8) requires manualChunks to be a function, not an object
216+
manualChunks: (id) => {
217+
if (id.includes('/preact/') || id.includes('/@preact/signals')) {
218+
return 'vendor'
219+
}
217220
},
218221
},
219222
// Ensure virtual modules are properly handled

0 commit comments

Comments
 (0)