fix: skip fields not supported by rolldown for rolldown-vite (#4747)

pull/4758/head
4 months ago committed by GitHub
parent ab0e0cb598
commit 4e3fce40c9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -1,6 +1,7 @@
import fs from 'fs-extra' import fs from 'fs-extra'
import path from 'node:path' import path from 'node:path'
import { fileURLToPath } from 'node:url' import { fileURLToPath } from 'node:url'
import * as vite from 'vite'
import { import {
build, build,
normalizePath, normalizePath,
@ -98,9 +99,12 @@ export async function bundle(
app: path.resolve(APP_PATH, ssr ? 'ssr.js' : 'index.js'), app: path.resolve(APP_PATH, ssr ? 'ssr.js' : 'index.js'),
...input ...input
}, },
// important so that each page chunk and the index export things for each // @ts-ignore skip setting it for rolldown-vite since it doesn't support `preserveEntrySignatures` yet
// other ...(vite.rolldownVersion
preserveEntrySignatures: 'allow-extension', ? undefined
: // important so that each page chunk and the index export things for each
// other
{ preserveEntrySignatures: 'allow-extension' }),
output: { output: {
sanitizeFileName, sanitizeFileName,
...rollupOptions?.output, ...rollupOptions?.output,
@ -118,44 +122,52 @@ export async function bundle(
? `${config.assetsDir}/chunks/ui-custom.[hash].js` ? `${config.assetsDir}/chunks/ui-custom.[hash].js`
: `${config.assetsDir}/chunks/[name].[hash].js` : `${config.assetsDir}/chunks/[name].[hash].js`
}, },
manualChunks(id, ctx) { // @ts-ignore skip setting it for rolldown-vite since it doesn't support `manualChunks`
// move known framework code into a stable chunk so that ...(vite.rolldownVersion
// custom theme changes do not invalidate hash for all pages ? undefined
if ( : {
id.startsWith('\0vite') || manualChunks(
ctx.getModuleInfo(id)?.meta['vite:asset'] id: string,
) { ctx: Pick<Rollup.PluginContext, 'getModuleInfo'>
return 'framework' ) {
} // move known framework code into a stable chunk so that
if (id.includes('plugin-vue:export-helper')) { // custom theme changes do not invalidate hash for all pages
return 'framework' if (
} id.startsWith('\0vite') ||
if ( ctx.getModuleInfo(id)?.meta['vite:asset']
id.includes(`${clientDir}/app`) && ) {
id !== `${clientDir}/app/index.js` return 'framework'
) { }
return 'framework' if (id.includes('plugin-vue:export-helper')) {
} return 'framework'
if ( }
isEagerChunk(id, ctx.getModuleInfo) && if (
/@vue\/(runtime|shared|reactivity)/.test(id) id.includes(`${clientDir}/app`) &&
) { id !== `${clientDir}/app/index.js`
return 'framework' ) {
} return 'framework'
}
if (
isEagerChunk(id, ctx.getModuleInfo) &&
/@vue\/(runtime|shared|reactivity)/.test(id)
) {
return 'framework'
}
if ( if (
(id.startsWith(`${clientDir}/theme-default`) || (id.startsWith(`${clientDir}/theme-default`) ||
!excludedModules.some((i) => id.includes(i))) && !excludedModules.some((i) => id.includes(i))) &&
staticImportedByEntry( staticImportedByEntry(
id, id,
ctx.getModuleInfo, ctx.getModuleInfo,
cacheTheme, cacheTheme,
themeEntryRE themeEntryRE
) )
) { ) {
return 'theme' return 'theme'
} }
} }
})
}) })
} }
} }

Loading…
Cancel
Save