Skip to content

Commit

Permalink
perf: improve prefetching and immutable state (#533)
Browse files Browse the repository at this point in the history
  • Loading branch information
manucorporat authored May 25, 2022
1 parent 1cc7c16 commit 7610aa4
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 33 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "qwik-monorepo",
"version": "0.0.20",
"version": "0.0.21-0",
"scripts": {
"build": "yarn node scripts --tsc --build --api --platform-binding-wasm-copy",
"build.full": "yarn node scripts --tsc --build --api --eslint --platform-binding --wasm",
Expand Down
2 changes: 1 addition & 1 deletion packages/create-qwik/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-qwik",
"version": "0.0.20",
"version": "0.0.21-0",
"description": "Interactive CLI and API for generating Qwik projects.",
"bin": "create-qwik",
"main": "index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"devDependencies": {
"@builder.io/partytown": "^0.5.4",
"@builder.io/qwik": "0.0.20",
"@builder.io/qwik-city": "0.0.6",
"@builder.io/qwik-city": "0.0.7",
"@cloudflare/kv-asset-handler": "0.2.0",
"@cloudflare/workers-types": "^3.10.0",
"autoprefixer": "10.4.7",
Expand Down
4 changes: 3 additions & 1 deletion packages/docs/pages/docs/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ Qwik is a new kind of web framework that can deliver instant loading web applica

<img
alt="Qwik Diagram"
src="https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2Fd33c7a95e98144f682ab67dd27d1f957?format=webp&width=2000"
width="1000"
height="640"
src="https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2Fd33c7a95e98144f682ab67dd27d1f957?format=webp&width=1000"
/>

## Does page speed really matter?
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-qwik/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-plugin-qwik",
"version": "0.0.20",
"version": "0.0.21-0",
"description": "An Open-Source sub-framework designed with a focus on server-side-rendering, lazy-loading, and styling/animation.",
"main": "index.js",
"author": "Builder Team",
Expand Down
2 changes: 1 addition & 1 deletion packages/qwik-city/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@builder.io/qwik-city",
"version": "0.0.6",
"version": "0.0.7",
"description": "Static Site Generator for Qwik",
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
Expand Down
16 changes: 8 additions & 8 deletions packages/qwik-city/src/runtime/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,23 +106,23 @@ export interface PageBreadcrumb {
// @public (undocumented)
export interface PageHandler {
// (undocumented)
attributes: PageAttributes;
readonly attributes: PageAttributes;
// (undocumented)
breadcrumbs: PageBreadcrumb[];
readonly breadcrumbs: PageBreadcrumb[];
// (undocumented)
content: Content;
readonly content: Content;
// (undocumented)
headings: PageHeading[];
readonly headings: PageHeading[];
// (undocumented)
index: {
readonly index: {
path: string;
};
// (undocumented)
layout: Layout;
readonly layout: Layout;
// (undocumented)
source: PageSource;
readonly source: PageSource;
// (undocumented)
url: string;
readonly url: string;
}

// @public (undocumented)
Expand Down
4 changes: 3 additions & 1 deletion packages/qwik-city/src/runtime/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
useStore,
noSerialize,
useContextProvider,
immutable,
} from '@builder.io/qwik';
import { BUILD_ID, INLINED_MODULES, LAYOUTS, PAGES } from '@builder.io/qwik-city/build';
import type { PageHandler } from './types';
Expand All @@ -18,7 +19,7 @@ export const QwikCityContext = createContext<PageHandler>('qwikcity-page');
*/
export const useQwikCity = () => {
const href = useLocation().href;
const page = useStore<PageHandler>({} as any);
const page: PageHandler = {} as any;
useWaitOn(
loadPage(href).then((loaded) => {
if (loaded) {
Expand All @@ -32,6 +33,7 @@ export const useQwikCity = () => {
content: noSerialize(loaded.content),
layout: noSerialize(loaded.layout),
});
immutable(page);
}
})
);
Expand Down
16 changes: 8 additions & 8 deletions packages/qwik-city/src/runtime/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
* @public
*/
export interface PageHandler {
attributes: PageAttributes;
breadcrumbs: PageBreadcrumb[];
content: Content;
headings: PageHeading[];
index: { path: string };
layout: Layout;
source: PageSource;
url: string;
readonly attributes: PageAttributes;
readonly breadcrumbs: PageBreadcrumb[];
readonly content: Content;
readonly headings: PageHeading[];
readonly index: { path: string };
readonly layout: Layout;
readonly source: PageSource;
readonly url: string;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/qwik/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@builder.io/qwik",
"version": "0.0.20",
"version": "0.0.21-0",
"description": "An Open-Source sub-framework designed with a focus on server-side-rendering, lazy-loading, and styling/animation.",
"main": "./dist/core.cjs",
"module": "./dist/core.mjs",
Expand Down
6 changes: 0 additions & 6 deletions packages/qwik/src/server/prefetch-strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,6 @@ function addBundle(
addBundle(manifest, urls, prefetchResource.imports, buildBase, importedFilename);
}
}

if (Array.isArray(bundle.dynamicImports)) {
for (const importedFilename of bundle.dynamicImports) {
addBundle(manifest, urls, prefetchResource.imports, buildBase, importedFilename);
}
}
}
}
}
13 changes: 10 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ __metadata:
languageName: node
linkType: hard

"@builder.io/[email protected].6, @builder.io/qwik-city@workspace:packages/qwik-city":
"@builder.io/[email protected].7, @builder.io/qwik-city@workspace:packages/qwik-city":
version: 0.0.0-use.local
resolution: "@builder.io/qwik-city@workspace:packages/qwik-city"
dependencies:
Expand Down Expand Up @@ -450,7 +450,14 @@ __metadata:
languageName: node
linkType: hard

"@builder.io/[email protected], @builder.io/qwik@workspace:packages/qwik":
"@builder.io/qwik@npm:0.0.20":
version: 0.0.20
resolution: "@builder.io/qwik@npm:0.0.20"
checksum: d8ce825fda6dafca7ce9ffc7eaa32166c622174acff7d73e542fff90bc0dfaf0ba70b56e3626744e26be532cf9887d9b3d5fbdfd3e0922da85972ac2e66fa73c
languageName: node
linkType: hard

"@builder.io/qwik@workspace:packages/qwik":
version: 0.0.0-use.local
resolution: "@builder.io/qwik@workspace:packages/qwik"
languageName: unknown
Expand Down Expand Up @@ -7621,7 +7628,7 @@ __metadata:
dependencies:
"@builder.io/partytown": ^0.5.4
"@builder.io/qwik": 0.0.20
"@builder.io/qwik-city": 0.0.6
"@builder.io/qwik-city": 0.0.7
"@cloudflare/kv-asset-handler": 0.2.0
"@cloudflare/workers-types": ^3.10.0
autoprefixer: 10.4.7
Expand Down

0 comments on commit 7610aa4

Please sign in to comment.