Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/every-suns-flow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@qwik.dev/astro": patch
---

Simplifies internals
2 changes: 1 addition & 1 deletion apps/website/src/content/docs/contributing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ There are two major files to be aware of: `index.ts` and `server.ts`.

## index.ts

The integration entrypoint, built with `astro-integration-kit`'s `defineIntegration`. It registers Qwik as an Astro renderer and configures the Vite plugins.
The integration entrypoint. It registers Qwik as an Astro renderer and configures the Vite plugins.

### Astro hooks

Expand Down
8 changes: 2 additions & 6 deletions libs/qwikdev-astro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,11 @@
},
"homepage": "https://qwik.dev/astro",
"bugs": "https://github.com/QwikDev/astro/issues",
"dependencies": {
"astro-integration-kit": "^0.20.0"
},
"devDependencies": {
"@qwik.dev/core": "2.0.0-beta.30",
"astro": "6.0.6",
"vite": "^7.3.1"
},
"peerDependencies": {
"@qwik.dev/core": ">=2.0.0-beta.30 <3.0.0"
"@qwik.dev/core": ">=2.0.0-beta.30 <3.0.0",
"astro": "^6.0.0"
}
}
33 changes: 0 additions & 33 deletions libs/qwikdev-astro/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import type { RenderOptions } from "@qwik.dev/core/server";
import { z } from "astro/zod";

export const INTEGRATION_NAME = "@qwik.dev/astro";

export const SERVER_ENTRYPOINT = "@qwik.dev/astro/server";
Expand All @@ -18,33 +15,3 @@ export const SCAN_EXTENSIONS = ["*.tsx", "*.jsx", "*.ts", "*.js"] as const;

export const QWIK_ENTRYPOINT_PATTERN =
/@builder\.io\/qwik|qwik\.dev\/core|qwik\.dev\/react|\.qwik\./;

export const FilterPatternSchema = z.union([
z.string(),
z.instanceof(RegExp),
z.array(z.union([z.string(), z.instanceof(RegExp)])).readonly(),
z.null()
]);

export const optionsSchema = z
.object({
/** Tell Qwik which files to process. */
include: FilterPatternSchema.optional(),

/** Tell Qwik which files to ignore. */
exclude: FilterPatternSchema.optional(),

/** Enable debug mode with the qwikVite plugin. */
debug: z.boolean().optional(),

/** Options passed into each Qwik component's `renderToStream` call. */
renderOpts: z
.custom<RenderOptions>((data) => {
return typeof data === "object" && data !== null;
})
.optional(),

/** Enable SPA-style navigation support with Astro's ClientRouter. */
clientRouter: z.boolean().optional()
})
.optional();
63 changes: 31 additions & 32 deletions libs/qwikdev-astro/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import { dirname } from "node:path";
import { fileURLToPath } from "node:url";
import type { RenderOptions } from "@qwik.dev/core";
import { qwikVite } from "@qwik.dev/core/optimizer";
import type { QwikManifest, QwikVitePluginOptions } from "@qwik.dev/core/optimizer";
import type { AstroConfig, AstroIntegration } from "astro";
import { defineIntegration, watchDirectory } from "astro-integration-kit";
import type { Plugin } from "vite";
import type { FilterPattern, Plugin } from "vite";
import { type ViteBuilder, createFilter } from "vite";
import {
INTEGRATION_NAME,
ROOT_ENTRYPOINT,
SERVER_ENTRYPOINT,
VIRTUAL_MODULE_NAME,
optionsSchema
} from "./constants";
import {
createAstroQwikPostPlugin,
Expand Down Expand Up @@ -80,34 +77,41 @@ export const clientRouter = ${JSON.stringify(clientRouter)};`;
};
}

/**
* This project uses Astro Integration Kit.
* @see https://astro-integration-kit.netlify.app/
*/
export default defineIntegration({
name: INTEGRATION_NAME,
optionsSchema,
type Options = {
/** Tell Qwik which files to process. */
include?: FilterPattern

/** Tell Qwik which files to ignore. */
exclude?: FilterPattern

/** Enable debug mode with the qwikVite plugin. */
debug?: boolean

/** Options passed into each Qwik component's `renderToStream` call. */
renderOpts?: RenderOptions

/** Enable SPA-style navigation support with Astro's ClientRouter. */
clientRouter?: boolean
}

setup({ options }) {
let srcDir = "";
let serverDir = "";
let finalDir = "";
export default function qwik(options?: Options): AstroIntegration {
let srcDir = "";
let serverDir = "";
let finalDir = "";

let qwikManifest: QwikManifest | null = null;
let qwikManifest: QwikManifest | null = null;

let astroConfig: AstroConfig | null = null;
const packageDir = dirname(fileURLToPath(import.meta.url));
const filter = createFilter(options?.include, options?.exclude);
let astroConfig: AstroConfig | null = null;
const filter = createFilter(options?.include, options?.exclude);

const lifecycleHooks: AstroIntegration["hooks"] = {
return {
name: INTEGRATION_NAME,
hooks: {
"astro:config:setup": async (setupProps) => {
const { addRenderer, updateConfig, config, command } = setupProps;
astroConfig = config;
const isDev = command === "dev";

// integration HMR support
watchDirectory(setupProps, packageDir);

addRenderer({
name: INTEGRATION_NAME,
serverEntrypoint: SERVER_ENTRYPOINT
Expand Down Expand Up @@ -199,11 +203,6 @@ export default defineIntegration({
await originalBuildApp(b);
};
}
};

return {
name: INTEGRATION_NAME,
hooks: lifecycleHooks
};
}
});
}
};
}
21 changes: 4 additions & 17 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading