Skip to content

V2 Repros version #239

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 11 commits into from
Closed
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
4 changes: 3 additions & 1 deletion apps/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
"astro": "astro"
},
"dependencies": {
"@builder.io/qwik": "^1.12.0",
"@qwikdev/astro": "workspace:*",
"astro": "5.1.1"
},
"devDependencies": {
"@qwik.dev/core": "2.0.0-alpha.8"
}
}
2 changes: 1 addition & 1 deletion apps/demo/src/components/qwik/counter.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Slot, component$, useSignal } from "@builder.io/qwik";
import { Slot, component$, useSignal } from "@qwik.dev/core";

export const Counter = component$<{ initial: number }>((props) => {
const counter = useSignal(props.initial);
Expand Down
2 changes: 1 addition & 1 deletion apps/demo/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
},

"jsx": "react-jsx",
"jsxImportSource": "@builder.io/qwik"
"jsxImportSource": "@qwik.dev/core"
}
}
74 changes: 74 additions & 0 deletions apps/deno-demo/deno.lock

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

4 changes: 3 additions & 1 deletion apps/deno-demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@
"@astrojs/check": "^0.9.4",
"@astrojs/deno": "^5.0.1",
"@astrojs/react": "^4.1.2",
"@builder.io/qwik": "^1.12.0",
"@qwikdev/astro": "workspace:*",
"@types/react": "^18.3.18",
"@types/react-dom": "^18.3.5",
"astro": "^5.1.1",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"typescript": "^5.7.2"
},
"devDependencies": {
"@qwik.dev/core": "2.0.0-alpha.8"
}
}
2 changes: 1 addition & 1 deletion apps/deno-demo/src/components/qwik/counter.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Slot, component$, useSignal } from "@builder.io/qwik";
import { Slot, component$, useSignal } from "@qwik.dev/core";

export const Counter = component$<{ initial: number }>((props) => {
const counter = useSignal(props.initial);
Expand Down
2 changes: 1 addition & 1 deletion apps/deno-demo/src/components/qwik/say-hi.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Slot, component$, sync$ } from "@builder.io/qwik";
import { Slot, component$, sync$ } from "@qwik.dev/core";

export const SayHi = component$(() => {
return (
Expand Down
2 changes: 1 addition & 1 deletion apps/deno-demo/src/components/qwik/test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { component$ } from "@builder.io/qwik";
import { component$ } from "@qwik.dev/core";

export const Test = component$(() => {
return <div>test</div>;
Expand Down
2 changes: 1 addition & 1 deletion apps/deno-demo/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
},

"jsx": "react-jsx",
"jsxImportSource": "@builder.io/qwik"
"jsxImportSource": "@qwik.dev/core"
}
}
4 changes: 3 additions & 1 deletion apps/node-demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@
"dependencies": {
"@astrojs/node": "9.0.0",
"@astrojs/react": "4.1.2",
"@builder.io/qwik": "^1.12.0",
"@qwikdev/astro": "workspace:*",
"@types/react": "^18.3.18",
"@types/react-dom": "^18.3.5",
"astro": "5.1.1",
"react": "^18.3.1",
"react-dom": "^18.3.1"
},
"devDependencies": {
"@qwik.dev/core": "2.0.0-alpha.8"
}
}
2 changes: 1 addition & 1 deletion apps/node-demo/src/components/qwik/counter.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Slot, component$, useSignal } from "@builder.io/qwik";
import { Slot, component$, useSignal } from "@qwik.dev/core";

export const Counter = component$<{ initial: number }>((props) => {
const counter = useSignal(props.initial);
Expand Down
2 changes: 1 addition & 1 deletion apps/node-demo/src/components/qwik/say-hi.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Slot, component$, sync$ } from "@builder.io/qwik";
import { Slot, component$, sync$ } from "@qwik.dev/core";

export const SayHi = component$(() => {
return (
Expand Down
2 changes: 1 addition & 1 deletion apps/node-demo/src/components/qwik/test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { component$ } from "@builder.io/qwik";
import { component$ } from "@qwik.dev/core";

export const Test = component$(() => {
return <div>test</div>;
Expand Down
2 changes: 1 addition & 1 deletion apps/node-demo/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
},

"jsx": "react-jsx",
"jsxImportSource": "@builder.io/qwik"
"jsxImportSource": "@qwik.dev/core"
}
}
6 changes: 3 additions & 3 deletions apps/website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
},
"dependencies": {
"@astrojs/check": "^0.9.4",
"@builder.io/qwik": "^1.12",
"@fontsource-variable/unbounded": "^5.1.1",
"@iconify-json/lucide": "^1.2.23",
"@qwikdev/astro": "^0.7",
"@qwikdev/astro": "workspace:*",
"astro": "^5.1",
"astro-icon": "^1.1.4",
"sharp": "^0.33.5"
},
"devDependencies": {
"@biomejs/biome": "^1.7.0"
"@biomejs/biome": "^1.7.0",
"@qwik.dev/core": "2.0.0-alpha.8"
}
}
2 changes: 1 addition & 1 deletion apps/website/src/components/home/background/background.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { component$, useStylesScoped$ } from "@builder.io/qwik";
import { component$, useStylesScoped$ } from "@qwik.dev/core";
import styles from "./background.css?inline";

export const Background = component$(() => {
Expand Down
2 changes: 1 addition & 1 deletion apps/website/src/components/home/bar-chart/bar-chart.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { component$, useStylesScoped$ } from "@builder.io/qwik";
import { component$, useStylesScoped$ } from "@qwik.dev/core";
import styles from "./bar-chart.css?inline";

interface BarChartProps {
Expand Down
2 changes: 1 addition & 1 deletion apps/website/src/components/home/cli-copy/cli-copy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
useSignal,
useStyles$,
useTask$
} from "@builder.io/qwik";
} from "@qwik.dev/core";
import styles from "./cli-copy.css?inline";

export const CLICopy = component$((props: PropsOf<"button">) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
useOnDocument,
useSignal,
useStylesScoped$
} from "@builder.io/qwik";
} from "@qwik.dev/core";
import { JSChunk } from "../js-chunk/js-chunk";

export const JSChunkAnimator = component$(() => {
Expand Down
2 changes: 1 addition & 1 deletion apps/website/src/components/home/js-chunk/js-chunk.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { component$, useStylesScoped$ } from "@builder.io/qwik";
import { component$, useStylesScoped$ } from "@qwik.dev/core";

export const JSChunk = component$(() => {
useStylesScoped$(
Expand Down
2 changes: 1 addition & 1 deletion apps/website/src/components/home/logo-hover/logo-hover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
useSignal,
useStyles$,
useVisibleTask$
} from "@builder.io/qwik";
} from "@qwik.dev/core";
import { AstroIcon } from "@icons/astro";
import { QwikIcon } from "@icons/qwik";
import styles from "./logo-hover.css?inline";
Expand Down
2 changes: 1 addition & 1 deletion apps/website/src/components/home/spotlight/spotlight.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { $, Slot, component$, useSignal, useStyles$ } from "@builder.io/qwik";
import { $, Slot, component$, useSignal, useStyles$ } from "@qwik.dev/core";
import styles from "./spotlight.css?inline";

export const Spotlight = component$(() => {
Expand Down
2 changes: 1 addition & 1 deletion apps/website/src/components/home/squiggle/squiggle.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type PropsOf, component$, useStylesScoped$ } from "@builder.io/qwik";
import { type PropsOf, component$, useStylesScoped$ } from "@qwik.dev/core";
import styles from "./squiggle.css?inline";

export const Squiggle = component$((props: PropsOf<"svg">) => {
Expand Down
2 changes: 1 addition & 1 deletion apps/website/src/icons/astro.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type PropsOf, component$ } from "@builder.io/qwik";
import { type PropsOf, component$ } from "@qwik.dev/core";

export const AstroIcon = component$((props: PropsOf<"svg">) => {
return (
Expand Down
2 changes: 1 addition & 1 deletion apps/website/src/icons/qwik.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type PropsOf, component$ } from "@builder.io/qwik";
import { type PropsOf, component$ } from "@qwik.dev/core";

export const QwikIcon = component$((props: PropsOf<"svg">) => {
return (
Expand Down
2 changes: 1 addition & 1 deletion apps/website/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
},

"jsx": "react-jsx",
"jsxImportSource": "@builder.io/qwik"
"jsxImportSource": "@qwik.dev/core"
}
}
8 changes: 3 additions & 5 deletions libs/qwikdev-astro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,9 @@
"astro-integration-kit": "^0.18.0"
},
"devDependencies": {
"@builder.io/qwik": "^1.12.0",
"@qwik.dev/core": "https://pkg.pr.new/QwikDev/qwik/@qwik.dev/core@7435",
"astro": "^5.1.1",
"vite": "^5.4.11"
},
"peerDependencies": {
"@builder.io/qwik": ">=1.9.0"
"vite": "^5.4.11",
"ts-morph": "latest"
}
}
61 changes: 25 additions & 36 deletions libs/qwikdev-astro/server.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
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 JSXNode, type JSXOutput, jsx } from "@qwik.dev/core";
import { isDev } from "@qwik.dev/core/build";
import type { QwikManifest } from "@qwik.dev/core/optimizer";
import {
type RenderToStreamOptions,
getQwikLoaderScript,
renderToStream
} from "@builder.io/qwik/server";
} from "@qwik.dev/core/server";
import type { SSRResult } from "astro";

const isQwikLoaderAddedMap = new WeakMap<SSRResult, boolean>();
Expand Down Expand Up @@ -103,7 +103,7 @@ export async function renderToStaticMarkup(
include: false
},
stream: {
write: (chunk) => {
write: (chunk: string) => {
html += chunk;
}
}
Expand Down Expand Up @@ -180,50 +180,39 @@ export async function renderToStaticMarkup(
renderToStreamOpts.containerAttributes!["q-astro-marker"] = "first";
}

await renderToStream(qwikComponentJSX, renderToStreamOpts);

// we only want to add the preloader script if the container is the last one
if (isDev && devUrls.size > 0) {
const preloaderScript = `<script q-astro-dev-preloader>
window.addEventListener("load",()=>{
const symbols = ${JSON.stringify(Array.from(devUrls))};
symbols.forEach(symbol => {
const link = document.createElement('link');
link.rel = 'modulepreload';
link.href = symbol;
link.fetchPriority = 'low';
document.head.appendChild(link);
});
});
</script>`;

// if there is one container, add the preloader script to the first one
if (html.includes('q-astro-marker="first"')) {
html += preloaderScript;
}

// if there is more than one container, add the preloader script to the last one
if (html.includes('q-astro-marker="last"')) {
html += preloaderScript;
}
}
await renderToStream(qwikComponentJSX as JSXOutput, renderToStreamOpts);

const isClientRouter = Array.from(this.result._metadata.renderedScripts).some(
(path) => path.includes("ClientRouter.astro")
);

const stateScript = html.replace(
'<script type="qwik/state"',
'<script type="qwik/state" data-astro-rerun>'
);

/** With View Transitions, rerun so that signals work
* https://docs.astro.build/en/guides/view-transitions/#data-astro-rerun
*/
const htmlWithRerun = html.replace(
'<script q:func="qwik/json">',
'<script q:func="qwik/json" data-astro-rerun>'
const signalState = stateScript.replace(
'<script q:func="qwik/json"',
'<script q:func="qwik/json" data-astro-rerun'
);

const clientVNode = signalState.replace(
'<script type="qwik/vnode"',
'<script type="qwik/vnode" data-astro-rerun'
);

const xQwikVNode = clientVNode.replace(
'<script type="x-qwik/vnode"',
'<script type="x-qwik/vnode" data-astro-rerun>'
);

/** Adds support for visible tasks with Astro's client router */
const htmlWithObservers =
isClientRouter &&
htmlWithRerun +
xQwikVNode +
`
${isQwikLoaderNeeded ? `<script data-qwik-astro-client-router>document.addEventListener('astro:after-swap',()=>{const e=document.querySelectorAll('[on\\\\:qvisible]');if(e.length){const o=new IntersectionObserver(e=>{e.forEach(e=>{e.isIntersecting&&(e.target.dispatchEvent(new CustomEvent('qvisible')),o.unobserve(e.target))})});e.forEach(e=>o.observe(e))}});</script>` : ""}
`;
Expand Down
Loading