Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
nermalcat69 authored Sep 21, 2024
2 parents aff4280 + ae09275 commit 27c37c9
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 31 deletions.
5 changes: 5 additions & 0 deletions .changeset/quiet-grapes-sit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@builder.io/qwik': patch
---

fix(optimizer): ignore unknown deps in graph causing crashes during build
6 changes: 2 additions & 4 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Download docs artifact
uses: actions/download-artifact@v4
Expand All @@ -38,9 +38,7 @@ jobs:

# not the official version, so be careful when updating
- name: Deploy to Cloudflare Pages
# if the docs didn't build, don't deploy but don't fail the workflow
if: success()
uses: AdrianGonz97/refined-cf-pages-action@f026b5a7c0cb4a05ecb63871c5fc4992cf036d7f
uses: AdrianGonz97/refined-cf-pages-action@6c0d47ff7c97c48fa702b6d9f71f7e3a7c30c7d8
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
Expand Down
6 changes: 3 additions & 3 deletions e2e/qwik-cli-e2e/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "qwik-cli-e2e",
"dependencies": {
"kleur": "4.1.5"
},
"private": true,
"scripts": {
"e2e": "vitest run --config=vite.config.ts",
"e2e:watch": "vitest watch --config=vite.config.ts"
},
"dependencies": {
"kleur": "4.1.5"
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@
"serve.debug": "tsm --inspect-brk --conditions=development starters/dev-server.ts 3300",
"start": "concurrently \"npm:build.watch\" \"npm:tsc.watch\" -n build,tsc -c green,cyan",
"test": "pnpm build.full && pnpm test.unit && pnpm test.e2e",
"test.e2e-cli": "pnpm --filter qwik-cli-e2e e2e",
"test.e2e": "pnpm test.e2e.chromium && pnpm test.e2e.webkit",
"test.e2e-cli": "pnpm --filter qwik-cli-e2e e2e",
"test.e2e.chromium": "playwright test starters --browser=chromium --config starters/playwright.config.ts",
"test.e2e.chromium.debug": "PWDEBUG=1 playwright test starters --browser=chromium --config starters/playwright.config.ts",
"test.e2e.city": "playwright test starters/e2e/qwikcity --browser=chromium --config starters/playwright.config.ts",
Expand Down
17 changes: 12 additions & 5 deletions packages/docs/src/routes/docs/(qwik)/advanced/containers/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ contributors:
- mhevery
- bab2683
- mrhoodz
updated_at: '2023-08-23T23:06:42Z'
updated_at: '2023-08-23T23:06:41Z'
created_at: '2023-03-20T23:45:13Z'
---

Expand All @@ -19,7 +19,14 @@ created_at: '2023-03-20T23:45:13Z'
Every Qwik application is contained inside a element, usually the `<html>` element. This element becomes the container for the application. The container is the root element for the application and all components, state and events are contained within.

```html
<html q:container="paused" q:version="0.12.1" q:base="/build">
<html
q:container="paused"
q:version="1.9.0"
q:render="ssr"
q:base="/build/"
q:manifest-hash="ggb7b3"
q:instance="b0yf84vwuup"
>
...
</html>
```
Expand All @@ -39,7 +46,7 @@ renderToStream(<Root />, {
The code above will render the following HTML:

```html
<html lang="en" q:container="paused" q:version="0.12.1" q:base="/build">
<html lang="en" q:container="paused" q:version="1.9.0" q:base="/build/">
...
</html>
```
Expand Down Expand Up @@ -68,12 +75,12 @@ Since the runtime ensures isolation across containers, several containers can co
Containers can be nested in a tree and can communicate and share data. The inter-component communication requires that the components have well-defined boundaries, which we call container protocols.

```html
<html q:container="paused" q:version="0.12.1" q:base="/build">
<html q:container="paused" q:version="1.9.0" q:base="/build/">
<head>
<title>My Qwik Application</title>
</head>
<body>
<header q:container="resumed" q:version="0.11.1" q:base="https://server.a/build">
<header q:container="resumed" q:version="1.8.0" q:base="https://server.a/build">
<div>
<h1>This is a header form a container</h1>
</div>
Expand Down
15 changes: 11 additions & 4 deletions packages/docs/src/routes/docs/(qwik)/components/tasks/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,14 @@ One unique aspect of Qwik, is that components are mounted only **once** across t

### `track()`

There are times when it is desirable to re-run a task when a component state changes. This is done by using the `track()` function. The `track()` function allows you to set up a dependency on a component's state when initially rendered on the server, and then re-execute the task when the state changes in the browser. The same task will never be executed twice on the server.
There are times when it is desirable to re-run a task when a component state changes. This is done by using the `track()` function. The `track()` function allows you to set up a dependency on a component's state when initially rendered on the server, and then re-execute the task when the state changes in the browser.

Track accepts signals, stores and functions. It returns the value of the signal, the store itself, or the function call result.

When you pass a store, the track will be called when the store gets or removes properties as well as mutations of properties.
Note that deep store updates don't mutate the store itself, so `store[item].count++` will not trigger an update. Instead, you should individually track each `store[item]` (which are also automatically created stores).

During SSR, each component will wait until all tasks are completed before outputting the HTML for that component. So a task can be called multiple times during SSR if the tracked state changes due to other tasks.

> **Note**: If all you want to do is compute a new state from an existing state synchronously, you should use [`useComputed$()`](/docs/components/state/#usecomputed) instead.
Expand All @@ -195,9 +202,9 @@ export default component$(() => {
const delayText = useSignal('');

useTask$(({ track }) => {
track(() => text.value);
const value = text.value;
const update = () => (delayText.value = value);
// Passing a signal directly is more efficient than using a function.
const newText = track(text);
const update = () => (delayText.value = newText);
isServer
? update() // don't delay on server render value as part of SSR
: delay(500).then(update); // Delay in browser
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ AUTH_SECRET=

```ts title="src/routes/[email protected]"
import { QwikAuth$ } from "@auth/qwik";
import GitHub from "@auth/qwik/providers/github";
import Credentials from "@auth/qwik/providers/credentials";

export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$(
() => ({
Expand Down
26 changes: 15 additions & 11 deletions packages/qwik/src/optimizer/src/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,16 +261,21 @@ export function generateManifestFromBundles(
const buildPath = path.resolve(opts.rootDir, opts.outDir, 'build');
const canonPath = (p: string) =>
path.relative(buildPath, path.resolve(opts.rootDir, opts.outDir, p));
const getBundleName = (name: string) => {
const bundle = outputBundles[name];
if (!bundle) {
console.warn(`Client manifest generation: skipping external import "${name}"`);
return;
}
return canonPath(bundle.fileName);
};
// We need to find our QRL exports
const qrlNames = new Set([...segments.map((h) => h.name)]);
for (const outputBundle of Object.values(outputBundles)) {
if (outputBundle.type !== 'chunk') {
continue;
}
const bundleFileName = path.relative(
buildPath,
path.resolve(opts.outDir, outputBundle.fileName)
);
const bundleFileName = canonPath(outputBundle.fileName);

const bundle: QwikBundle = {
size: outputBundle.code.length,
Expand All @@ -296,19 +301,18 @@ export function generateManifestFromBundles(
}

const bundleImports = outputBundle.imports
// Tree shaking can maybe remove imports
// Tree shaking might remove imports
.filter((i) => outputBundle.code.includes(path.basename(i)))
.map((i) => canonPath(outputBundles[i].fileName || i));
.map((i) => getBundleName(i))
.filter(Boolean) as string[];
if (bundleImports.length > 0) {
bundle.imports = bundleImports;
}

const bundleDynamicImports = outputBundle.dynamicImports
.filter(
// Tree shaking can remove dynamic imports
(i) => outputBundle.code.includes(path.basename(i))
)
.map((i) => canonPath(outputBundles[i].fileName || i));
.filter((i) => outputBundle.code.includes(path.basename(i)))
.map((i) => getBundleName(i))
.filter(Boolean) as string[];
if (bundleDynamicImports.length > 0) {
bundle.dynamicImports = bundleDynamicImports;
}
Expand Down
8 changes: 6 additions & 2 deletions packages/qwik/src/optimizer/src/plugins/vite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1135,6 +1135,10 @@ export function convertManifestToBundleGraph(manifest: QwikManifest): QwikBundle
const map = new Map<string, { index: number; deps: Set<string> }>();
const clearTransitiveDeps = (parentDeps: Set<string>, seen: Set<string>, bundleName: string) => {
const bundle = graph[bundleName];
if (!bundle) {
// external dependency
return;
}
for (const dep of bundle.imports || []) {
if (parentDeps.has(dep)) {
parentDeps.delete(dep);
Expand All @@ -1151,7 +1155,7 @@ export function convertManifestToBundleGraph(manifest: QwikManifest): QwikBundle
const deps = new Set(bundle.imports);
for (const depName of deps) {
if (!graph[depName]) {
// weird but ok
// external dependency
continue;
}
clearTransitiveDeps(deps, new Set(), depName);
Expand All @@ -1161,7 +1165,7 @@ export function convertManifestToBundleGraph(manifest: QwikManifest): QwikBundle
// If we dynamically import a qrl segment that is not a handler, we'll probably need it soon
const dep = graph[depName];
if (!graph[depName]) {
// weird but ok
// external dependency
continue;
}
if (dep.isTask) {
Expand Down

0 comments on commit 27c37c9

Please sign in to comment.