diff --git a/.changeset/famous-snakes-drum.md b/.changeset/famous-snakes-drum.md new file mode 100644 index 00000000..7b3e3223 --- /dev/null +++ b/.changeset/famous-snakes-drum.md @@ -0,0 +1,5 @@ +--- +"@qwikdev/astro": patch +--- + +fix: support for Astro navigate function and virtual modules diff --git a/libs/qwikdev-astro/q-astro-manifest.json b/libs/qwikdev-astro/q-astro-manifest.json index b6d0d781..f00f6d21 100644 --- a/libs/qwikdev-astro/q-astro-manifest.json +++ b/libs/qwikdev-astro/q-astro-manifest.json @@ -1 +1 @@ -{"manifestHash":"uvwr9a","symbols":{"s_Jkq4JnSu3vc":{"origin":"components/qwik/counter.tsx","displayName":"counter.tsx_Counter_component","canonicalFilename":"counter.tsx_Counter_component_Jkq4JnSu3vc","hash":"Jkq4JnSu3vc","ctxKind":"function","ctxName":"component$","captures":false,"loc":[121,301]},"s_o0dE1oWgGK4":{"origin":"../../../libs/qwikdev-astro/src/root.tsx","displayName":"root.tsx_root_component","canonicalFilename":"root.tsx_root_component_o0dE1oWgGK4","hash":"o0dE1oWgGK4","ctxKind":"function","ctxName":"component$","captures":false,"loc":[81,136]},"s_WTj7Z5OCKjk":{"origin":"components/qwik/counter.tsx","displayName":"counter.tsx_Counter_component_button_onClick","canonicalFilename":"counter.tsx_Counter_component_button_onClick_WTj7Z5OCKjk","hash":"WTj7Z5OCKjk","ctxKind":"eventHandler","ctxName":"onClick$","captures":true,"parent":"s_Jkq4JnSu3vc","loc":[226,247]}},"mapping":{"s_Jkq4JnSu3vc":"q-gxfui5gO.js","s_o0dE1oWgGK4":"q-BVmDhJRY.js","s_WTj7Z5OCKjk":"q-D0icCluT.js"},"bundles":{"q-BVmDhJRY.js":{"size":61649,"origins":["../../libs/qwikdev-astro/src/root.tsx_root_component_o0dE1oWgGK4.js","../../node_modules/.pnpm/@builder.io+qwik@1.12.0_vite@6.0.6_@types+node@22.10.2_jiti@2.4.2_yaml@2.6.1_/node_modules/@builder.io/qwik/dist/core.prod.mjs","@builder.io/qwik/build"],"symbols":["s_o0dE1oWgGK4"]},"q-C4FN6EFX.js":{"size":184,"imports":["q-BVmDhJRY.js","q-D0icCluT.js"],"dynamicImports":["q-BVmDhJRY.js"],"origins":["../../libs/qwikdev-astro/src/root.tsx"]},"q-CyizIga3.js":{"size":171,"imports":["q-BVmDhJRY.js","q-D0icCluT.js"],"dynamicImports":["q-gxfui5gO.js"],"origins":["src/components/qwik/counter.tsx"]},"q-D0icCluT.js":{"size":1610,"imports":["q-BVmDhJRY.js"],"origins":["src/components/qwik/counter.tsx_Counter_component_Jkq4JnSu3vc.js","src/components/qwik/counter.tsx_Counter_component_button_onClick_WTj7Z5OCKjk.js"],"symbols":["s_WTj7Z5OCKjk"]},"q-gxfui5gO.js":{"size":88,"imports":["q-BVmDhJRY.js","q-D0icCluT.js"],"symbols":["s_Jkq4JnSu3vc"]}},"injections":[],"version":"1","options":{"target":"client","buildMode":"production","entryStrategy":{"type":"smart"}},"platform":{"qwik":"1.12.0","vite":"","rollup":"4.29.1","env":"node","os":"linux","node":"22.12.0"}} \ No newline at end of file +{"manifestHash":"dxopp8","symbols":{"s_Jkq4JnSu3vc":{"origin":"components/qwik/counter.tsx","displayName":"counter.tsx_s","canonicalFilename":"counter.tsx_s_Jkq4JnSu3vc","hash":"Jkq4JnSu3vc","ctxKind":"function","ctxName":"component$","captures":false,"loc":[929,942]},"s_o0dE1oWgGK4":{"origin":"../../../libs/qwikdev-astro/src/root.tsx","displayName":"root.tsx_root_component","canonicalFilename":"root.tsx_root_component_o0dE1oWgGK4","hash":"o0dE1oWgGK4","ctxKind":"function","ctxName":"component$","captures":false,"loc":[81,136]},"s_WTj7Z5OCKjk":{"origin":"components/qwik/counter.tsx","displayName":"counter.tsx_s","canonicalFilename":"counter.tsx_s_WTj7Z5OCKjk","hash":"WTj7Z5OCKjk","ctxKind":"function","ctxName":"_jsxQ","captures":true,"loc":[626,639]}},"mapping":{"s_Jkq4JnSu3vc":"q-CbgFd24z.js","s_o0dE1oWgGK4":"q-BVmDhJRY.js","s_WTj7Z5OCKjk":"q-BUgo_UOC.js"},"bundles":{"q-BUgo_UOC.js":{"size":93,"imports":["q-BVmDhJRY.js","q-CbgFd24z.js"],"origins":["src/components/qwik/counter.tsx_s_WTj7Z5OCKjk.js"],"symbols":["s_WTj7Z5OCKjk"]},"q-BVmDhJRY.js":{"size":61649,"origins":["../../libs/qwikdev-astro/src/root.tsx_root_component_o0dE1oWgGK4.js","../../node_modules/.pnpm/@builder.io+qwik@1.12.0_vite@6.0.6_@types+node@22.10.2_jiti@2.4.2_yaml@2.6.1_/node_modules/@builder.io/qwik/dist/core.prod.mjs","@builder.io/qwik/build"],"symbols":["s_o0dE1oWgGK4"]},"q-BZLo5_WJ.js":{"size":146,"imports":["q-BVmDhJRY.js","q-CbgFd24z.js"]},"q-C3ZwI676.js":{"size":184,"imports":["q-BVmDhJRY.js","q-CbgFd24z.js"],"dynamicImports":["q-BVmDhJRY.js"],"origins":["../../libs/qwikdev-astro/src/root.tsx"]},"q-CbgFd24z.js":{"size":1694,"imports":["q-BVmDhJRY.js"],"dynamicImports":["q-BUgo_UOC.js"],"origins":["src/components/qwik/counter.tsx","src/components/qwik/counter.tsx_s_Jkq4JnSu3vc.js"],"symbols":["s_Jkq4JnSu3vc"]}},"injections":[],"version":"1","options":{"target":"client","buildMode":"production","entryStrategy":{"type":"smart"}},"platform":{"qwik":"1.12.0","vite":"","rollup":"4.29.1","env":"node","os":"darwin","node":"22.12.0"}} \ No newline at end of file diff --git a/libs/qwikdev-astro/src/index.ts b/libs/qwikdev-astro/src/index.ts index 57388725..33aaaf16 100644 --- a/libs/qwikdev-astro/src/index.ts +++ b/libs/qwikdev-astro/src/index.ts @@ -58,6 +58,7 @@ export default defineIntegration({ let serverDir = ""; let outDir = ""; let finalDir = ""; + let astroVite: InlineConfig; let resolveEntrypoints: () => void; const entrypointsReady = new Promise((resolve) => { @@ -233,6 +234,10 @@ export default defineIntegration({ astroConfig = config; }, + "astro:build:setup": async ({ vite }) => { + astroVite = vite as InlineConfig; + }, + "astro:build:ssr": async () => { await entrypointsReady; @@ -259,10 +264,39 @@ export default defineIntegration({ debug: options?.debug ?? false }; - // client build -> passed into server build + // determine which plugins from core to keep + const astroPlugins = ( + astroVite.plugins?.flatMap((p) => (Array.isArray(p) ? p : [p])) ?? [] + ) + .filter((plugin): plugin is { name: string } & NonNullable => { + return plugin != null && typeof plugin === "object" && "name" in plugin; + }) + .filter((plugin) => { + const isCoreBuildPlugin = plugin.name === "astro:build"; + const isAstroInternalPlugin = plugin.name.includes("@astro"); + const isAllowedPlugin = + plugin.name === "astro:transitions" || plugin.name.includes("virtual"); + const isAstroBuildPlugin = plugin.name.startsWith("astro:build"); + const isQwikPlugin = + plugin.name === "vite-plugin-qwik" || + plugin.name === "vite-plugin-qwik-post" || + plugin.name === "overrideEsbuild"; + + if (isAllowedPlugin) { + return true; + } + + return !( + isCoreBuildPlugin || + isAstroInternalPlugin || + isAstroBuildPlugin || + isQwikPlugin + ); + }); + await build({ ...astroConfig?.vite, - plugins: [qwikVite(qwikClientConfig)], + plugins: [...astroPlugins, qwikVite(qwikClientConfig)], build: { ...astroConfig?.vite?.build, ssr: false,