Skip to content

Commit

Permalink
feat: major perf improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
thejackshelton committed Jul 11, 2024
1 parent 448193b commit 9aa38bb
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 19 deletions.
6 changes: 6 additions & 0 deletions .changeset/small-ways-taste.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@qwikdev/create-astro": minor
"@qwikdev/astro": minor
---

refactor: major performance improvements
2 changes: 1 addition & 1 deletion apps/node-demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"dependencies": {
"@astrojs/node": "^8.2.3",
"@astrojs/react": "^3.0.10",
"@builder.io/qwik": "^1.7",
"@builder.io/qwik": "^1.7.1",
"@qwikdev/astro": "workspace:*",
"@types/react": "^18.2.64",
"@types/react-dom": "^18.2.21",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"dependencies": {
"@astrojs/check": "^0.5.10",
"@astrojs/deno": "^5.0.1",
"@builder.io/qwik": "1.5.6",
"@builder.io/qwik": "^1.7.1",
"@qwikdev/astro": "^0.5.13",
"astro": "^4.5.12",
"typescript": "^5.4.3"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"dependencies": {
"@astrojs/check": "^0.5.10",
"@astrojs/deno": "^5.0.1",
"@builder.io/qwik": "1.5.6",
"@builder.io/qwik": "^1.7.1",
"@qwikdev/astro": "^0.5.14",
"astro": "^4.6.3",
"typescript": "^5.4.5"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"dependencies": {
"@astrojs/check": "^0.5.10",
"@astrojs/node": "^8.2.5",
"@builder.io/qwik": "1.5.6",
"@builder.io/qwik": "^1.7.1",
"@qwikdev/astro": "^0.5.14",
"astro": "^4.6.3",
"typescript": "^5.4.5"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"dependencies": {
"@astrojs/check": "^0.5.10",
"@astrojs/node": "^8.2.5",
"@builder.io/qwik": "1.5.6",
"@builder.io/qwik": "^1.7.1",
"@qwikdev/astro": "^0.5.14",
"astro": "^4.6.3",
"typescript": "^5.4.5"
Expand Down
4 changes: 2 additions & 2 deletions libs/qwikdev-astro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@
"vite-tsconfig-paths": "^4.2.1"
},
"devDependencies": {
"@builder.io/qwik": "^1.7",
"@builder.io/qwik": "^1.7.1",
"@types/fs-extra": "^11.0.4",
"@types/node": "^20.10.0",
"astro": "^4.5",
"typescript": "^5.4.2",
"vite": "^5.3"
},
"peerDependencies": {
"@builder.io/qwik": "^1.7",
"@builder.io/qwik": "^1.7.1",
"typescript": "^5.4.2"
}
}
3 changes: 2 additions & 1 deletion libs/qwikdev-astro/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
import { isDev } from "@builder.io/qwik/build";
import { getQwikLoaderScript, renderToString } from "@builder.io/qwik/server";
import { manifest } from "@qwik-client-manifest";
import { type QwikManifest } from "@builder.io/qwik/optimizer";

const qwikLoaderAdded = new WeakMap<SSRResult, boolean>();

Expand Down Expand Up @@ -107,7 +108,7 @@ export async function renderToStaticMarkup(
containerTagName: "div",
containerAttributes: { style: "display: contents" },
...(isDev
? { manifest: {} as QwikManifest, symbolMapper: globalThis._mymapper }
? { manifest: {} as QwikManifest, symbolMapper: globalThis.symbolMapper }
: { manifest }),
qwikLoader: { include: "never" }
});
Expand Down
26 changes: 19 additions & 7 deletions libs/qwikdev-astro/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,18 @@ import type { AstroConfig } from "astro";
import { z } from "astro/zod";
import ts from "typescript";

import { qwikVite } from "@builder.io/qwik/optimizer";
import { qwikVite, type SymbolMapperFn } from "@builder.io/qwik/optimizer";
import { defineIntegration } from "astro-integration-kit";
import { watchIntegrationPlugin } from "astro-integration-kit/plugins";
import { symbolMapper, type QwikManifest } from '@builder.io/qwik/optimizer';
import { symbolMapper } from '@builder.io/qwik/optimizer';

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

declare global {
var symbolMapper: SymbolMapperFn;

Check failure on line 23 in libs/qwikdev-astro/src/index.ts

View workflow job for this annotation

GitHub Actions / 👷 CI @QwikDev/astro on Node-lts/* under ubuntu-latest

Shouldn't redeclare 'symbolMapper'. Consider to delete it or rename it.

Check failure on line 23 in libs/qwikdev-astro/src/index.ts

View workflow job for this annotation

GitHub Actions / 👷 CI @QwikDev/astro on Node-lts/* under ubuntu-latest

Shouldn't redeclare 'symbolMapper'. Consider to delete it or rename it.
}

/* Similar to vite's FilterPattern */
const FilternPatternSchema = z.union([
z.string(),
Expand Down Expand Up @@ -108,10 +112,18 @@ export default defineIntegration({
},

plugins: [
{name:"grabSymbolMapper", configResolved() { globalThis._mymapper = symbolMapper }},
{
name: "grabSymbolMapper",
configResolved() {
/** We need to get the symbolMapper straight from qwikVite here. You can think of it as the "manifest" for dev mode. */
globalThis.symbolMapper = symbolMapper;
setTimeout(() => {
console.log("\x1b[32m[Qwik Astro]: Ignore the Vite emitFile warning, as it's not an issue and this error message will be resolved in the next Qwik version.\x1b[0m");
}, 5000)
}
},
qwikVite({
/* user passed include & exclude config (to use multiple JSX frameworks) */
debug: true,
fileFilter: (id: string, hook: string) => {
if (hook === "transform" && !filter(id)) {
return false;
Expand All @@ -131,7 +143,7 @@ export default defineIntegration({
},
ssr: {
input: "@qwikdev/astro/server"
}
},
}),
tsconfigPaths(),
{
Expand Down Expand Up @@ -166,15 +178,15 @@ export default defineIntegration({
enforce: "pre",
name: "astro-noop",

load(id) {
load(id: string) {
if (id.endsWith(".astro")) {
return "export default function() {}";
}
return null;
}
}
]
} as InlineConfig);
} as unknown as InlineConfig);

await moveArtifacts(distDir, tempDir);
} else {
Expand Down
29 changes: 25 additions & 4 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 9aa38bb

Please sign in to comment.