Skip to content

Commit 2b27088

Browse files
authored
refactor(router): improve plugin retrieval logic in Vite adapter (#8001)
* refactor(router): improve plugin retrieval logic in Vite adapter * refactor(router): unify plugin retrieval logic in Vite adapter and buildtime plugin * refactor(router): add double type assertion to avoid TypeScript stack depth error in plugin retrieval
1 parent e436baa commit 2b27088

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

packages/qwik-router/src/adapters/shared/vite/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,11 @@ export function viteAdapter(opts: ViteAdapterPluginOptions) {
4848
if (!qwikRouterPlugin) {
4949
throw new Error('Missing vite-plugin-qwik-router');
5050
}
51+
// Use double type assertion to avoid TS "Excessive stack depth comparing types" error
52+
// when comparing QwikVitePlugin with Plugin types
5153
qwikVitePlugin = config.plugins.find(
5254
(p) => p.name === 'vite-plugin-qwik'
53-
) as QwikVitePlugin;
55+
) as any as QwikVitePlugin;
5456
if (!qwikVitePlugin) {
5557
throw new Error('Missing vite-plugin-qwik');
5658
}

packages/qwik-router/src/buildtime/vite/plugin.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,11 @@ function qwikRouterPlugin(userOpts?: QwikRouterVitePluginOptions): any {
133133
await validatePlugin(ctx.opts);
134134

135135
mdxTransform = await createMdxTransformer(ctx);
136-
137-
qwikPlugin = config.plugins.find((p) => p.name === 'vite-plugin-qwik') as QwikVitePlugin;
136+
// Use double type assertion to avoid TS "Excessive stack depth comparing types" error
137+
// when comparing QwikVitePlugin with Plugin types
138+
qwikPlugin = config.plugins.find(
139+
(p) => p.name === 'vite-plugin-qwik'
140+
) as any as QwikVitePlugin;
138141
if (!qwikPlugin) {
139142
throw new Error('Missing vite-plugin-qwik');
140143
}

0 commit comments

Comments
 (0)