Skip to content

Commit 4e3fce4

Browse files
authored
fix: skip fields not supported by rolldown for rolldown-vite (#4747)
1 parent ab0e0cb commit 4e3fce4

File tree

1 file changed

+52
-40
lines changed

1 file changed

+52
-40
lines changed

src/node/build/bundle.ts

Lines changed: 52 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import fs from 'fs-extra'
22
import path from 'node:path'
33
import { fileURLToPath } from 'node:url'
4+
import * as vite from 'vite'
45
import {
56
build,
67
normalizePath,
@@ -98,9 +99,12 @@ export async function bundle(
9899
app: path.resolve(APP_PATH, ssr ? 'ssr.js' : 'index.js'),
99100
...input
100101
},
101-
// important so that each page chunk and the index export things for each
102-
// other
103-
preserveEntrySignatures: 'allow-extension',
102+
// @ts-ignore skip setting it for rolldown-vite since it doesn't support `preserveEntrySignatures` yet
103+
...(vite.rolldownVersion
104+
? undefined
105+
: // important so that each page chunk and the index export things for each
106+
// other
107+
{ preserveEntrySignatures: 'allow-extension' }),
104108
output: {
105109
sanitizeFileName,
106110
...rollupOptions?.output,
@@ -118,44 +122,52 @@ export async function bundle(
118122
? `${config.assetsDir}/chunks/ui-custom.[hash].js`
119123
: `${config.assetsDir}/chunks/[name].[hash].js`
120124
},
121-
manualChunks(id, ctx) {
122-
// move known framework code into a stable chunk so that
123-
// custom theme changes do not invalidate hash for all pages
124-
if (
125-
id.startsWith('\0vite') ||
126-
ctx.getModuleInfo(id)?.meta['vite:asset']
127-
) {
128-
return 'framework'
129-
}
130-
if (id.includes('plugin-vue:export-helper')) {
131-
return 'framework'
132-
}
133-
if (
134-
id.includes(`${clientDir}/app`) &&
135-
id !== `${clientDir}/app/index.js`
136-
) {
137-
return 'framework'
138-
}
139-
if (
140-
isEagerChunk(id, ctx.getModuleInfo) &&
141-
/@vue\/(runtime|shared|reactivity)/.test(id)
142-
) {
143-
return 'framework'
144-
}
125+
// @ts-ignore skip setting it for rolldown-vite since it doesn't support `manualChunks`
126+
...(vite.rolldownVersion
127+
? undefined
128+
: {
129+
manualChunks(
130+
id: string,
131+
ctx: Pick<Rollup.PluginContext, 'getModuleInfo'>
132+
) {
133+
// move known framework code into a stable chunk so that
134+
// custom theme changes do not invalidate hash for all pages
135+
if (
136+
id.startsWith('\0vite') ||
137+
ctx.getModuleInfo(id)?.meta['vite:asset']
138+
) {
139+
return 'framework'
140+
}
141+
if (id.includes('plugin-vue:export-helper')) {
142+
return 'framework'
143+
}
144+
if (
145+
id.includes(`${clientDir}/app`) &&
146+
id !== `${clientDir}/app/index.js`
147+
) {
148+
return 'framework'
149+
}
150+
if (
151+
isEagerChunk(id, ctx.getModuleInfo) &&
152+
/@vue\/(runtime|shared|reactivity)/.test(id)
153+
) {
154+
return 'framework'
155+
}
145156

146-
if (
147-
(id.startsWith(`${clientDir}/theme-default`) ||
148-
!excludedModules.some((i) => id.includes(i))) &&
149-
staticImportedByEntry(
150-
id,
151-
ctx.getModuleInfo,
152-
cacheTheme,
153-
themeEntryRE
154-
)
155-
) {
156-
return 'theme'
157-
}
158-
}
157+
if (
158+
(id.startsWith(`${clientDir}/theme-default`) ||
159+
!excludedModules.some((i) => id.includes(i))) &&
160+
staticImportedByEntry(
161+
id,
162+
ctx.getModuleInfo,
163+
cacheTheme,
164+
themeEntryRE
165+
)
166+
) {
167+
return 'theme'
168+
}
169+
}
170+
})
159171
})
160172
}
161173
}

0 commit comments

Comments
 (0)