Skip to content

Commit

Permalink
update to latest of AIK
Browse files Browse the repository at this point in the history
  • Loading branch information
thejackshelton committed Aug 4, 2024
1 parent a6b7ee0 commit 6bad706
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 18 deletions.
2 changes: 1 addition & 1 deletion libs/qwikdev-astro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
},
"bugs": "https://github.com/thejackshelton/@qwikdev/astro/issues",
"dependencies": {
"astro-integration-kit": "^0.2",
"astro-integration-kit": "^0.16",
"fs-extra": "^11.1.1",
"fs-move": "^6.0.0",
"vite-tsconfig-paths": "^4.2.1"
Expand Down
20 changes: 9 additions & 11 deletions libs/qwikdev-astro/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { rmSync } from "node:fs";
import { lstat, readdir, readlink } from "node:fs/promises";
import { dirname, join, normalize, relative, resolve } from "node:path";

import type { AstroConfig } from "astro";
import type { AstroConfig, AstroIntegration } from "astro";
import { z } from "astro/zod";
import ts from "typescript";

Expand All @@ -18,8 +18,6 @@ import {
} from "@builder.io/qwik/optimizer";
import { symbolMapper } from "@builder.io/qwik/optimizer";
import { defineIntegration } from "astro-integration-kit";
import { watchIntegrationPlugin } from "astro-integration-kit/plugins";

import { type InlineConfig, type PluginOption, build, createFilter } from "vite";
import tsconfigPaths from "vite-tsconfig-paths";

Expand All @@ -29,7 +27,7 @@ declare global {
}

/* Similar to vite's FilterPattern */
const FilternPatternSchema = z.union([
const FilterPatternSchema = z.union([
z.string(),
z.instanceof(RegExp),
z.array(z.union([z.string(), z.instanceof(RegExp)])).readonly(),
Expand All @@ -51,10 +49,9 @@ const qwikModules = [

export default defineIntegration({
name: "@qwikdev/astro",
plugins: [watchIntegrationPlugin],
optionsSchema: z.object({
include: FilternPatternSchema.optional(),
exclude: FilternPatternSchema.optional()
include: FilterPatternSchema.optional(),
exclude: FilterPatternSchema.optional()
}),

setup({ options }) {
Expand All @@ -66,17 +63,14 @@ export default defineIntegration({
const tempDir = join(`tmp-${newHash()}`);
const filter = createFilter(options.include, options.exclude);

return {
const lifecycleHooks: AstroIntegration["hooks"] = {
"astro:config:setup": async ({
addRenderer,
updateConfig,
config,
command,
injectScript
}) => {
// // Integration HMR
// watchIntegration(resolve());

// Because Astro uses the same port for both dev and preview, we need to unregister the SW in order to avoid a stale SW in dev mode.
if (command === "dev") {
const unregisterSW =
Expand Down Expand Up @@ -232,6 +226,10 @@ export default defineIntegration({
}
}
};

return {
hooks: lifecycleHooks
};
}
});

Expand Down
44 changes: 38 additions & 6 deletions pnpm-lock.yaml

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

0 comments on commit 6bad706

Please sign in to comment.