Skip to content

Commit 361cf35

Browse files
committed
chore: fix plugin types
they somehow got broken by updates
1 parent 65dd404 commit 361cf35

File tree

14 files changed

+58
-48
lines changed

14 files changed

+58
-48
lines changed

Diff for: packages/docs/src/routes/api/qwik-optimizer/api.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@
484484
}
485485
],
486486
"kind": "Interface",
487-
"content": "```typescript\nexport interface QwikVitePlugin \n```\n\n\n<table><thead><tr><th>\n\nProperty\n\n\n</th><th>\n\nModifiers\n\n\n</th><th>\n\nType\n\n\n</th><th>\n\nDescription\n\n\n</th></tr></thead>\n<tbody><tr><td>\n\n[api](#)\n\n\n</td><td>\n\n\n</td><td>\n\n[QwikVitePluginApi](#qwikvitepluginapi)\n\n\n</td><td>\n\n\n</td></tr>\n<tr><td>\n\n[name](#)\n\n\n</td><td>\n\n\n</td><td>\n\n'vite-plugin-qwik'\n\n\n</td><td>\n\n\n</td></tr>\n</tbody></table>",
487+
"content": "```typescript\nexport interface QwikVitePlugin extends P<QwikVitePluginApi> \n```\n**Extends:** P&lt;[QwikVitePluginApi](#qwikvitepluginapi)<!-- -->&gt;\n\n\n<table><thead><tr><th>\n\nProperty\n\n\n</th><th>\n\nModifiers\n\n\n</th><th>\n\nType\n\n\n</th><th>\n\nDescription\n\n\n</th></tr></thead>\n<tbody><tr><td>\n\n[name](#)\n\n\n</td><td>\n\n\n</td><td>\n\n'vite-plugin-qwik'\n\n\n</td><td>\n\n\n</td></tr>\n</tbody></table>",
488488
"editUrl": "https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/optimizer/src/plugins/vite.ts",
489489
"mdFile": "qwik.qwikviteplugin.md"
490490
},

Diff for: packages/docs/src/routes/api/qwik-optimizer/index.md

+3-14
Original file line numberDiff line numberDiff line change
@@ -2216,9 +2216,11 @@ _(Optional)_
22162216
## QwikVitePlugin
22172217

22182218
```typescript
2219-
export interface QwikVitePlugin
2219+
export interface QwikVitePlugin extends P<QwikVitePluginApi>
22202220
```
22212221

2222+
**Extends:** P&lt;[QwikVitePluginApi](#qwikvitepluginapi)&gt;
2223+
22222224
<table><thead><tr><th>
22232225

22242226
Property
@@ -2238,19 +2240,6 @@ Description
22382240
</th></tr></thead>
22392241
<tbody><tr><td>
22402242

2241-
[api](#)
2242-
2243-
</td><td>
2244-
2245-
</td><td>
2246-
2247-
[QwikVitePluginApi](#qwikvitepluginapi)
2248-
2249-
</td><td>
2250-
2251-
</td></tr>
2252-
<tr><td>
2253-
22542243
[name](#)
22552244

22562245
</td><td>

Diff for: packages/qwik-city/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
"@mdx-js/mdx": "^3.0.1",
88
"@types/mdx": "^2.0.13",
99
"source-map": "^0.7.4",
10-
"svgo": "^3.2.0",
10+
"svgo": "3.3.2",
1111
"undici": "*",
1212
"vfile": "6.0.1",
13-
"vite": "^5.2.10",
14-
"vite-imagetools": "^6.2.9",
13+
"vite": "5.3.4",
14+
"vite-imagetools": "7.0.4",
1515
"zod": "^3.22.4"
1616
},
1717
"devDependencies": {

Diff for: packages/qwik-city/src/adapters/shared/api.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export const STATIC_PATHS_ID = "@qwik-city-static-paths";
3838
// Warning: (ae-forgotten-export) The symbol "ViteAdapterPluginOptions" needs to be exported by the entry point index.d.ts
3939
//
4040
// @public (undocumented)
41-
export function viteAdapter(opts: ViteAdapterPluginOptions): Plugin_2<any>;
41+
export function viteAdapter(opts: ViteAdapterPluginOptions): Plugin_2<never>;
4242

4343
// (No @packageDocumentation comment for this package)
4444

Diff for: packages/qwik-city/src/adapters/shared/vite/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export function viteAdapter(opts: ViteAdapterPluginOptions) {
2121
let format = 'esm';
2222
const outputEntries: string[] = [];
2323

24-
const plugin: Plugin = {
24+
const plugin: Plugin<never> = {
2525
name: `vite-plugin-qwik-city-${opts.name}`,
2626
enforce: 'post',
2727
apply: 'build',

Diff for: packages/qwik-city/src/buildtime/vite/api.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import type { BuiltinsWithOptionalParams } from 'svgo/plugins/plugins-types';
88
import type { CompileOptions } from '@mdx-js/mdx';
99
import type { Config } from 'svgo';
1010
import { ConfigEnv } from 'vite';
11+
import type { Plugin as Plugin_2 } from 'vite';
1112
import type { PluginOption } from 'vite';
1213
import { UserConfigExport } from 'vite';
1314

@@ -20,12 +21,11 @@ export type MdxOptions = CompileOptions;
2021
// @public (undocumented)
2122
export function qwikCity(userOpts?: QwikCityVitePluginOptions): PluginOption[];
2223

24+
// Warning: (ae-forgotten-export) The symbol "P" needs to be exported by the entry point index.d.ts
25+
// Warning: (ae-forgotten-export) The symbol "QwikCityPluginApi" needs to be exported by the entry point index.d.ts
26+
//
2327
// @public (undocumented)
24-
export interface QwikCityPlugin {
25-
// Warning: (ae-forgotten-export) The symbol "QwikCityPluginApi" needs to be exported by the entry point index.d.ts
26-
//
27-
// (undocumented)
28-
api: QwikCityPluginApi;
28+
export interface QwikCityPlugin extends P<QwikCityPluginApi> {
2929
// (undocumented)
3030
name: 'vite-plugin-qwik-city';
3131
}

Diff for: packages/qwik-city/src/buildtime/vite/plugin.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ function qwikCityPlugin(userOpts?: QwikCityVitePluginOptions): any {
5757
},
5858
};
5959

60-
const plugin: Plugin = {
60+
type P<T> = Plugin<T> & { api: T };
61+
62+
const plugin: P<QwikCityPluginApi> = {
6163
name: 'vite-plugin-qwik-city',
6264
enforce: 'pre',
6365
api,

Diff for: packages/qwik-city/src/buildtime/vite/types.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { MdxTransform } from '../markdown/mdx';
33
import type { BuildContext, BuildEntry, BuildRoute, PluginOptions, MdxPlugins } from '../types';
44
import type { Config as SVGOConfig } from 'svgo';
55
import type { BuiltinsWithOptionalParams as SVGOBuiltinPluginsWithOptionalParams } from 'svgo/plugins/plugins-types';
6+
import type { Plugin as VitePlugin } from 'vite';
67

78
/** @public */
89
export interface ImageOptimizationOptions {
@@ -39,10 +40,11 @@ export interface PluginContext {
3940
mdxTransform: MdxTransform | null;
4041
}
4142

43+
type P<T> = VitePlugin<T> & { api: T };
44+
4245
/** @public */
43-
export interface QwikCityPlugin {
46+
export interface QwikCityPlugin extends P<QwikCityPluginApi> {
4447
name: 'vite-plugin-qwik-city';
45-
api: QwikCityPluginApi;
4648
}
4749

4850
/** @public */

Diff for: packages/qwik-react/package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@
3535
"license": "MIT",
3636
"main": "./lib/index.qwik.mjs",
3737
"peerDependencies": {
38-
"@builder.io/qwik": "workspace:^",
39-
"@types/react": "^18.2.79",
40-
"@types/react-dom": "^18.2.25",
41-
"react": "^18.2.0",
42-
"react-dom": "^18.2.0"
38+
"@builder.io/qwik": "1.7.3",
39+
"@types/react": "18.3.3",
40+
"@types/react-dom": "18.3.0",
41+
"react": "18.3.1",
42+
"react-dom": "18.3.1"
4343
},
4444
"qwik": "./lib/index.qwik.mjs",
4545
"repository": {

Diff for: packages/qwik-worker/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"license": "MIT",
2525
"main": "./lib/index.qwik.mjs",
2626
"peerDependencies": {
27-
"@builder.io/qwik": "workspace:^"
27+
"@builder.io/qwik": "1.7.3"
2828
},
2929
"qwik": "./lib/index.qwik.mjs",
3030
"repository": {

Diff for: packages/qwik/src/optimizer/src/api.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
55
```ts
66

7+
import type { Plugin as Plugin_2 } from 'vite';
8+
79
// @public (undocumented)
810
export interface ComponentEntryStrategy {
911
// (undocumented)
@@ -296,10 +298,10 @@ export interface QwikViteDevResponse {
296298
_qwikRenderResolve?: () => void;
297299
}
298300

301+
// Warning: (ae-forgotten-export) The symbol "P" needs to be exported by the entry point index.d.ts
302+
//
299303
// @public (undocumented)
300-
export interface QwikVitePlugin {
301-
// (undocumented)
302-
api: QwikVitePluginApi;
304+
export interface QwikVitePlugin extends P<QwikVitePluginApi> {
303305
// (undocumented)
304306
name: 'vite-plugin-qwik';
305307
}

Diff for: packages/qwik/src/optimizer/src/plugins/rollup.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import type {
77
QwikManifest,
88
TransformModuleInput,
99
TransformModule,
10+
Optimizer,
1011
} from '../types';
1112
import {
1213
createPlugin,
@@ -18,6 +19,11 @@ import {
1819
} from './plugin';
1920
import { versions } from '../versions';
2021

22+
type QwikRollupPluginApi = {
23+
getOptimizer: () => Optimizer;
24+
getOptions: () => NormalizedQwikPluginOptions;
25+
};
26+
2127
/** @public */
2228
export function qwikRollup(qwikRollupOpts: QwikRollupPluginOptions = {}): any {
2329
const qwikPlugin = createPlugin(qwikRollupOpts.optimizerOptions);
@@ -323,5 +329,5 @@ export interface QwikRollupPluginOptions {
323329
*/
324330
lint?: boolean;
325331
}
326-
327-
export interface QwikRollupPlugin extends Rollup.Plugin {}
332+
type P<T> = Rollup.Plugin<T> & { api: T };
333+
export interface QwikRollupPlugin extends P<QwikRollupPluginApi> {}

Diff for: packages/qwik/src/optimizer/src/plugins/vite.ts

+12-6
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,15 @@ const DEDUPE = [QWIK_CORE_ID, QWIK_JSX_RUNTIME_ID, QWIK_JSX_DEV_RUNTIME_ID];
4040
const STYLING = ['.css', '.scss', '.sass', '.less', '.styl', '.stylus'];
4141
const FONTS = ['.woff', '.woff2', '.ttf'];
4242

43+
/**
44+
* Workaround to make the api be defined in the type.
45+
*
46+
* @internal
47+
*/
48+
type P<T> = VitePlugin<T> & { api: T; config: Extract<VitePlugin<T>['config'], Function> };
49+
4350
/** @public */
44-
export function qwikVite(qwikViteOpts: QwikVitePluginOptions = {}): any {
51+
export function qwikVite(qwikViteOpts: QwikVitePluginOptions = {}) {
4552
let isClientDevOnly = false;
4653
let clientDevInput: undefined | string = undefined;
4754
let tmpClientManifestPath: undefined | string = undefined;
@@ -91,7 +98,7 @@ export function qwikVite(qwikViteOpts: QwikVitePluginOptions = {}): any {
9198
// Vite hooks. The second plugin is a post plugin that is called after the build has finished.
9299
// The post plugin is used to generate the Qwik manifest file that is used during SSR to
93100
// generate QRLs for event handlers.
94-
const vitePluginPre: VitePlugin = {
101+
const vitePluginPre: P<QwikVitePluginApi> = {
95102
name: 'vite-plugin-qwik',
96103
enforce: 'pre',
97104
api,
@@ -478,7 +485,7 @@ export function qwikVite(qwikViteOpts: QwikVitePluginOptions = {}): any {
478485
},
479486
};
480487

481-
const vitePluginPost: VitePlugin = {
488+
const vitePluginPost: VitePlugin<never> = {
482489
name: 'vite-plugin-qwik-post',
483490
enforce: 'post',
484491

@@ -729,7 +736,7 @@ export function qwikVite(qwikViteOpts: QwikVitePluginOptions = {}): any {
729736
},
730737
};
731738

732-
return [vitePluginPre, vitePluginPost];
739+
return [vitePluginPre, vitePluginPost] as const;
733740
}
734741

735742
const ANSI_COLOR = {
@@ -1063,9 +1070,8 @@ export interface QwikVitePluginApi {
10631070
}
10641071

10651072
/** @public */
1066-
export interface QwikVitePlugin {
1073+
export interface QwikVitePlugin extends P<QwikVitePluginApi> {
10671074
name: 'vite-plugin-qwik';
1068-
api: QwikVitePluginApi;
10691075
}
10701076

10711077
/** @public */

Diff for: packages/qwik/src/optimizer/src/plugins/vite.unit.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ test('should use the dist/ fallback with client target', async () => {
320320
const plugin = qwikVite(initOpts)[0];
321321
const c: any = (await plugin.config(
322322
{ build: { assetsDir: 'my-assets-dir/' } },
323-
{ command: 'serve' }
323+
{ command: 'serve', mode: 'development' }
324324
))!;
325325

326326
assert.equal(c.build.outDir, normalizePath(resolve(cwd, `dist`)));
@@ -333,7 +333,7 @@ test('should use build.outDir config with client target', async () => {
333333
const plugin = qwikVite(initOpts)[0];
334334
const c: any = (await plugin.config(
335335
{ build: { outDir: 'my-dist/', assetsDir: 'my-assets-dir' } },
336-
{ command: 'serve' }
336+
{ command: 'serve', mode: 'development' }
337337
))!;
338338

339339
assert.equal(c.build.outDir, normalizePath(resolve(cwd, `my-dist`)));
@@ -347,7 +347,10 @@ test('should use build.outDir config when assetsDir is _astro', async () => {
347347
const plugin = qwikVite(initOpts)[0];
348348

349349
// Astro sets a build.assetsDir of _astro, but we don't want to change that
350-
const c: any = (await plugin.config({ build: { assetsDir: '_astro' } }, { command: 'serve' }))!;
350+
const c: any = (await plugin.config(
351+
{ build: { assetsDir: '_astro' } },
352+
{ command: 'serve', mode: 'development' }
353+
))!;
351354

352355
assert.equal(c.build.outDir, normalizePath(resolve(cwd, `dist/`)));
353356
});

0 commit comments

Comments
 (0)