@@ -7,28 +7,29 @@ import type {
77 SymbolMapperFn
88} from "@builder.io/qwik/optimizer" ;
99import type { RenderOptions } from "@builder.io/qwik/server" ;
10+ import aikMod from "@inox-tools/aik-mod" ;
1011import type { AstroConfig , AstroIntegration } from "astro" ;
11- import { createResolver , defineIntegration , watchDirectory , withPlugins } from "astro-integration-kit" ;
12+ import {
13+ createResolver ,
14+ defineIntegration ,
15+ watchDirectory ,
16+ withPlugins
17+ } from "astro-integration-kit" ;
1218import { z } from "astro/zod" ;
1319import { type PluginOption , build , createFilter } from "vite" ;
1420import type { InlineConfig } from "vite" ;
15- import aikMod from '@inox-tools/aik-mod' ;
1621
1722// TODO: contributing this back to aik-mod where we export the type
1823type DefineModuleOptions = {
1924 constExports ?: Record < string , unknown > ;
2025 defaultExport ?: unknown ;
2126} ;
2227
23- type SetupPropsWithAikMod =
24- Parameters <
25- NonNullable < AstroIntegration [ "hooks" ] [ "astro:config:setup" ] >
26- > [ 0 ] & {
27- defineModule : (
28- name : string ,
29- options : DefineModuleOptions
30- ) => string ;
31- } ;
28+ type SetupPropsWithAikMod = Parameters <
29+ NonNullable < AstroIntegration [ "hooks" ] [ "astro:config:setup" ] >
30+ > [ 0 ] & {
31+ defineModule : ( name : string , options : DefineModuleOptions ) => string ;
32+ } ;
3233
3334declare global {
3435 var symbolMapperFn : SymbolMapperFn ;
@@ -69,11 +70,13 @@ export default defineIntegration({
6970 */
7071 debug : z . boolean ( ) . optional ( ) ,
7172 /**
72- * Options passed into each Qwik component's `renderToStream` call.
73+ * Options passed into each Qwik component's `renderToStream` call.
7374 */
74- renderOpts : z . custom < RenderOptions > ( ( data ) => {
75- return typeof data === "object" && data !== null ;
76- } ) . optional ( )
75+ renderOpts : z
76+ . custom < RenderOptions > ( ( data ) => {
77+ return typeof data === "object" && data !== null ;
78+ } )
79+ . optional ( )
7780 } )
7881 . optional ( ) ,
7982
@@ -98,7 +101,8 @@ export default defineIntegration({
98101
99102 const lifecycleHooks : AstroIntegration [ "hooks" ] = {
100103 "astro:config:setup" : async ( setupProps ) => {
101- const { addRenderer, updateConfig, config, defineModule } = setupProps as SetupPropsWithAikMod ;
104+ const { addRenderer, updateConfig, config, defineModule } =
105+ setupProps as SetupPropsWithAikMod ;
102106 astroConfig = config ;
103107 // integration HMR support
104108 watchDirectory ( setupProps , resolver ( ) ) ;
@@ -107,7 +111,7 @@ export default defineIntegration({
107111 serverEntrypoint : resolver ( "../server.ts" )
108112 } ) ;
109113
110- defineModule ( ' virtual:qwikdev-astro' , {
114+ defineModule ( " virtual:qwikdev-astro" , {
111115 constExports : {
112116 renderOpts : options ?. renderOpts ?? { }
113117 }
@@ -174,7 +178,10 @@ export default defineIntegration({
174178
175179 const resolved = await this . resolve ( id , importer ) ;
176180 if ( ! resolved ) {
177- throw new Error ( `Could not resolve ${ id } from ${ importer } ` ) ;
181+ if ( options ?. debug ) {
182+ console . debug ( `Could not resolve ${ id } from ${ importer } ` ) ;
183+ }
184+ return null ;
178185 }
179186
180187 if ( resolved . id . includes ( ".qwik." ) ) {
@@ -356,4 +363,4 @@ export default defineIntegration({
356363
357364function getRelativePath ( from : string , to : string ) {
358365 return to . replace ( from , "" ) || "." ;
359- }
366+ }
0 commit comments