Skip to content

Commit daf0598

Browse files
authored
Merge pull request #7799 from QwikDev/fix-rolldown-vite-types
fix(build): make types rolldown-vite compatible
2 parents 3d48145 + 1cf663e commit daf0598

File tree

4 files changed

+17
-22
lines changed

4 files changed

+17
-22
lines changed

packages/qwik/src/optimizer/src/manifest.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { OutputBundle } from 'rollup';
1+
import type { Rollup } from 'vite';
22
import { type NormalizedQwikPluginOptions } from './plugins/plugin';
33
import type { GlobalInjections, Path, QwikBundle, QwikManifest, SegmentAnalysis } from './types';
44

@@ -392,7 +392,7 @@ export function generateManifestFromBundles(
392392
path: Path,
393393
segments: SegmentAnalysis[],
394394
injections: GlobalInjections[],
395-
outputBundles: OutputBundle,
395+
outputBundles: Rollup.OutputBundle,
396396
opts: NormalizedQwikPluginOptions,
397397
debug: (...args: any[]) => void,
398398
canonPath: (p: string) => string

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

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import type {
2020
ServerQwikManifest,
2121
} from '../types';
2222
import { createLinter, type QwikLinter } from './eslint-plugin';
23-
import type { LoadResult, OutputBundle, ResolveIdResult, TransformResult } from 'rollup';
2423
import { isWin, parseId } from './vite-utils';
2524
import type { BundleGraphAdder } from '..';
2625
import { convertManifestToBundleGraph } from './bundle-graph';
@@ -465,7 +464,7 @@ export function createQwikPlugin(optimizerOptions: OptimizerOptions = {}) {
465464
const parsedId = parseId(id);
466465
const pathId = normalizePath(parsedId.pathId);
467466

468-
let result: ResolveIdResult;
467+
let result: Rollup.ResolveIdResult;
469468

470469
/** At this point, the request has been normalized. */
471470

@@ -576,7 +575,7 @@ export function createQwikPlugin(optimizerOptions: OptimizerOptions = {}) {
576575
ctx: Rollup.PluginContext,
577576
id: string,
578577
loadOpts?: Parameters<Extract<Plugin['load'], Function>>[1]
579-
): Promise<LoadResult> => {
578+
): Promise<Rollup.LoadResult> => {
580579
if (id.startsWith('\0') || id.startsWith('/@fs/')) {
581580
return;
582581
}
@@ -641,8 +640,8 @@ export function createQwikPlugin(optimizerOptions: OptimizerOptions = {}) {
641640
ctx: Rollup.PluginContext,
642641
code: string,
643642
id: string,
644-
transformOpts: Parameters<Extract<Plugin['transform'], Function>>[2] = {}
645-
): Promise<TransformResult> {
643+
transformOpts = {} as Parameters<Extract<Plugin['transform'], Function>>[2]
644+
): Promise<Rollup.TransformResult> {
646645
if (id.startsWith('\0')) {
647646
return;
648647
}
@@ -787,7 +786,7 @@ export function createQwikPlugin(optimizerOptions: OptimizerOptions = {}) {
787786
canonPath: (p: string) => string;
788787
};
789788

790-
const createOutputAnalyzer = (rollupBundle: OutputBundle) => {
789+
const createOutputAnalyzer = (rollupBundle: Rollup.OutputBundle) => {
791790
const injections: GlobalInjections[] = [];
792791

793792
const outputAnalyzer: OutputAnalyzer = {
@@ -927,7 +926,10 @@ export const manifest = ${JSON.stringify(serverManifest)};\n`;
927926
}
928927
}
929928

930-
function manualChunks(id: string, { getModuleInfo }: Rollup.ManualChunkMeta) {
929+
function manualChunks(
930+
id: string,
931+
{ getModuleInfo }: Parameters<Extract<Rollup.OutputOptions['manualChunks'], Function>>[1]
932+
) {
931933
if (opts.target === 'client') {
932934
if (
933935
// The preloader has to stay in a separate chunk if it's a client build
@@ -956,7 +958,7 @@ export const manifest = ${JSON.stringify(serverManifest)};\n`;
956958

957959
async function generateManifest(
958960
ctx: Rollup.PluginContext,
959-
rollupBundle: OutputBundle,
961+
rollupBundle: Rollup.OutputBundle,
960962
bundleGraphAdders?: Set<BundleGraphAdder>,
961963
manifestExtra?: Partial<QwikManifest>
962964
) {

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { UserConfig, ViteDevServer, Plugin as VitePlugin } from 'vite';
1+
import type { UserConfig, ViteDevServer, Plugin as VitePlugin, BuildOptions } from 'vite';
22
import { QWIK_LOADER_DEFAULT_DEBUG, QWIK_LOADER_DEFAULT_MINIFIED } from '../scripts';
33
import type {
44
EntryStrategy,
@@ -326,7 +326,8 @@ export function qwikVite(qwikViteOpts: QwikVitePluginOptions = {}): any {
326326
output: {
327327
manualChunks: qwikPlugin.manualChunks,
328328
},
329-
},
329+
// temporary fix for rolldown-vite types
330+
} as BuildOptions['rollupOptions'],
330331
},
331332
define: {
332333
[qDevKey]: qDev,

packages/qwik/src/optimizer/src/plugins/vite.unit.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,20 @@ import { qwikVite, type QwikVitePlugin, type QwikVitePluginOptions } from './vit
77

88
const cwd = process.cwd();
99

10-
const chunkInfoMocks: Rollup.PreRenderedChunk[] = [
10+
const chunkInfoMocks = [
1111
{
1212
exports: [''],
1313
name: 'chunk.tsx',
1414
facadeModuleId: 'chunk.tsx',
15-
isDynamicEntry: false,
16-
isEntry: false,
17-
isImplicitEntry: false,
1815
moduleIds: ['chunk.tsx'],
19-
type: 'chunk',
2016
},
2117
{
2218
exports: [''],
2319
name: cwd + '/app/chunk.tsx',
2420
facadeModuleId: cwd + '/app/chunk.tsx',
25-
isDynamicEntry: false,
26-
isEntry: false,
27-
isImplicitEntry: false,
2821
moduleIds: [cwd + '/app/chunk.tsx'],
29-
type: 'chunk',
3022
},
31-
];
23+
] as Rollup.PreRenderedChunk[];
3224

3325
function mockOptimizerOptions(): OptimizerOptions {
3426
return {

0 commit comments

Comments
 (0)