diff --git a/.changeset/witty-papayas-obey.md b/.changeset/witty-papayas-obey.md
new file mode 100644
index 00000000..0a130931
--- /dev/null
+++ b/.changeset/witty-papayas-obey.md
@@ -0,0 +1,5 @@
+---
+"@qwikdev/astro": major
+---
+
+fix: return null instead of throwing on unresolved modules in resolveId
diff --git a/apps/demo/src/components/qwik/counter.tsx b/apps/demo/src/components/qwik/counter.tsx
index c66a382e..a576d1f4 100644
--- a/apps/demo/src/components/qwik/counter.tsx
+++ b/apps/demo/src/components/qwik/counter.tsx
@@ -1,12 +1,14 @@
import { Slot, component$, useSignal } from "@builder.io/qwik";
-import { type RenderOptions } from "@builder.io/qwik/server";
+import type { RenderOptions } from "@builder.io/qwik/server";
-export const Counter = component$<{ initial: number; renderOpts?: RenderOptions }>((props) => {
- const counter = useSignal(props.initial);
+export const Counter = component$<{ initial: number; renderOpts?: RenderOptions }>(
+ (props) => {
+ const counter = useSignal(props.initial);
- return (
-
- );
-});
+ return (
+
+ );
+ }
+);
diff --git a/libs/qwikdev-astro/package.json b/libs/qwikdev-astro/package.json
index 49f3c0de..14cf712e 100644
--- a/libs/qwikdev-astro/package.json
+++ b/libs/qwikdev-astro/package.json
@@ -40,12 +40,7 @@
"./utils": "./src/utils.ts",
"./q-astro-manifest.json": "./q-astro-manifest.json"
},
- "files": [
- "src",
- "src/index.ts",
- "server.ts",
- "env.d.ts"
- ],
+ "files": ["src", "src/index.ts", "server.ts", "env.d.ts"],
"keywords": [
"astro-integration",
"astro-component",
diff --git a/libs/qwikdev-astro/server.ts b/libs/qwikdev-astro/server.ts
index 6fed783e..1b614467 100644
--- a/libs/qwikdev-astro/server.ts
+++ b/libs/qwikdev-astro/server.ts
@@ -1,9 +1,9 @@
+import { renderOpts as globalRenderOpts } from "virtual:qwikdev-astro";
import { type JSXNode, jsx } from "@builder.io/qwik";
import { isDev } from "@builder.io/qwik/build";
import type { QwikManifest } from "@builder.io/qwik/optimizer";
import { type RenderToStreamOptions, renderToStream } from "@builder.io/qwik/server";
import type { SSRResult } from "astro";
-import { renderOpts as globalRenderOpts } from "virtual:qwikdev-astro";
const containerMap = new WeakMap();
@@ -62,7 +62,6 @@ export async function renderToStaticMarkup(
props: Record,
slotted: any
) {
-
try {
if (!isQwikComponent(component)) {
return;
@@ -93,7 +92,7 @@ export async function renderToStaticMarkup(
write: (chunk) => {
html += chunk;
}
- },
+ }
};
// https://qwik.dev/docs/components/overview/#inline-components
diff --git a/libs/qwikdev-astro/src/index.ts b/libs/qwikdev-astro/src/index.ts
index 588554a5..e043f8c5 100644
--- a/libs/qwikdev-astro/src/index.ts
+++ b/libs/qwikdev-astro/src/index.ts
@@ -7,12 +7,17 @@ import type {
SymbolMapperFn
} from "@builder.io/qwik/optimizer";
import type { RenderOptions } from "@builder.io/qwik/server";
+import aikMod from "@inox-tools/aik-mod";
import type { AstroConfig, AstroIntegration } from "astro";
-import { createResolver, defineIntegration, watchDirectory, withPlugins } from "astro-integration-kit";
+import {
+ createResolver,
+ defineIntegration,
+ watchDirectory,
+ withPlugins
+} from "astro-integration-kit";
import { z } from "astro/zod";
import { type PluginOption, build, createFilter } from "vite";
import type { InlineConfig } from "vite";
-import aikMod from '@inox-tools/aik-mod';
// TODO: contributing this back to aik-mod where we export the type
type DefineModuleOptions = {
@@ -20,15 +25,11 @@ type DefineModuleOptions = {
defaultExport?: unknown;
};
-type SetupPropsWithAikMod =
- Parameters<
- NonNullable
- >[0] & {
- defineModule: (
- name: string,
- options: DefineModuleOptions
- ) => string;
- };
+type SetupPropsWithAikMod = Parameters<
+ NonNullable
+>[0] & {
+ defineModule: (name: string, options: DefineModuleOptions) => string;
+};
declare global {
var symbolMapperFn: SymbolMapperFn;
@@ -69,11 +70,13 @@ export default defineIntegration({
*/
debug: z.boolean().optional(),
/**
- * Options passed into each Qwik component's `renderToStream` call.
+ * Options passed into each Qwik component's `renderToStream` call.
*/
- renderOpts: z.custom((data) => {
- return typeof data === "object" && data !== null;
- }).optional()
+ renderOpts: z
+ .custom((data) => {
+ return typeof data === "object" && data !== null;
+ })
+ .optional()
})
.optional(),
@@ -98,7 +101,8 @@ export default defineIntegration({
const lifecycleHooks: AstroIntegration["hooks"] = {
"astro:config:setup": async (setupProps) => {
- const { addRenderer, updateConfig, config, defineModule } = setupProps as SetupPropsWithAikMod;
+ const { addRenderer, updateConfig, config, defineModule } =
+ setupProps as SetupPropsWithAikMod;
astroConfig = config;
// integration HMR support
watchDirectory(setupProps, resolver());
@@ -107,7 +111,7 @@ export default defineIntegration({
serverEntrypoint: resolver("../server.ts")
});
- defineModule('virtual:qwikdev-astro', {
+ defineModule("virtual:qwikdev-astro", {
constExports: {
renderOpts: options?.renderOpts ?? {}
}
@@ -174,7 +178,10 @@ export default defineIntegration({
const resolved = await this.resolve(id, importer);
if (!resolved) {
- throw new Error(`Could not resolve ${id} from ${importer}`);
+ if (options?.debug) {
+ console.debug(`Could not resolve ${id} from ${importer}`);
+ }
+ return null;
}
if (resolved.id.includes(".qwik.")) {
@@ -356,4 +363,4 @@ export default defineIntegration({
function getRelativePath(from: string, to: string) {
return to.replace(from, "") || ".";
-}
\ No newline at end of file
+}
diff --git a/libs/qwikdev-astro/src/virtual.d.ts b/libs/qwikdev-astro/src/virtual.d.ts
index cfc1c03f..d8929617 100644
--- a/libs/qwikdev-astro/src/virtual.d.ts
+++ b/libs/qwikdev-astro/src/virtual.d.ts
@@ -1,6 +1,6 @@
declare module "virtual:qwikdev-astro" {
import type { RenderOptions } from "@builder.io/qwik/server";
-
+
const renderOpts: RenderOptions;
export { renderOpts };
}