Skip to content

Commit 568cfcd

Browse files
committed
fix: type casts to bridge Rollup vs Rolldown ✨
1 parent fcfe925 commit 568cfcd

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

.changeset/smooth-ends-count.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@builder.io/qwik': patch
3+
---
4+
5+
fix: type casts to bridge Rollup vs Rolldown type differences without changing runtime behavior

packages/qwik/src/optimizer/src/plugins/rollup.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,12 @@ export async function normalizeRollupOutputOptionsObject(
236236
if (prevManualChunks && typeof prevManualChunks !== 'function') {
237237
throw new Error('manualChunks must be a function');
238238
}
239+
// Casts bridge Rollup vs Rolldown ManualChunkMeta type differences
240+
type ManualChunkFn = (id: string, meta: unknown) => string | void | null;
239241
outputOpts.manualChunks = prevManualChunks
240-
? (id, meta) => prevManualChunks(id, meta) || manualChunks(id, meta)
241-
: manualChunks;
242+
? (id, meta) =>
243+
(prevManualChunks as ManualChunkFn)(id, meta) || (manualChunks as ManualChunkFn)(id, meta)
244+
: (manualChunks as Rollup.OutputOptions['manualChunks']);
242245
}
243246

244247
if (!outputOpts.dir) {
@@ -272,7 +275,9 @@ export async function normalizeRollupOutputOptionsObject(
272275
Number.isFinite(major) &&
273276
(major > 4 || (major === 4 && (minor > 52 || (minor === 52 && (patch || 0) >= 0))));
274277
if (isGte452) {
275-
outputOpts.onlyExplicitManualChunks = true;
278+
(
279+
outputOpts as Rollup.OutputOptions & { onlyExplicitManualChunks?: boolean }
280+
).onlyExplicitManualChunks = true;
276281
} else {
277282
console.warn(
278283
`⚠️ We detected that you're using a Rollup version prior to 4.52.0 (${version}). For the latest and greatest, we recommend to let Vite install the latest version for you, or manually install the latest version of Rollup in your project if that doesn't work. It will enable the new Rollup \`outputOpts.onlyExplicitManualChunks\` feature flag, which improves preloading performance and reduces cache invalidation for a snappier user experience.`

0 commit comments

Comments
 (0)