From 7610aa4764c0a075a30fe35a58c3102c5a8818f8 Mon Sep 17 00:00:00 2001 From: Manu MA Date: Wed, 25 May 2022 16:06:59 -0700 Subject: [PATCH] perf: improve prefetching and immutable state (#533) --- package.json | 2 +- packages/create-qwik/package.json | 2 +- packages/docs/package.json | 2 +- packages/docs/pages/docs/overview.mdx | 4 +++- packages/eslint-plugin-qwik/package.json | 2 +- packages/qwik-city/package.json | 2 +- packages/qwik-city/src/runtime/api.md | 16 ++++++++-------- packages/qwik-city/src/runtime/page.ts | 4 +++- packages/qwik-city/src/runtime/types.ts | 16 ++++++++-------- packages/qwik/package.json | 2 +- packages/qwik/src/server/prefetch-strategy.ts | 6 ------ yarn.lock | 13 ++++++++++--- 12 files changed, 38 insertions(+), 33 deletions(-) diff --git a/package.json b/package.json index a1d5231b6ac..d380aae87fd 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/packages/create-qwik/package.json b/packages/create-qwik/package.json index dcfb69b70b6..a43de68adcb 100644 --- a/packages/create-qwik/package.json +++ b/packages/create-qwik/package.json @@ -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", diff --git a/packages/docs/package.json b/packages/docs/package.json index e5eae3b290f..4548b8a77cd 100644 --- a/packages/docs/package.json +++ b/packages/docs/package.json @@ -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", diff --git a/packages/docs/pages/docs/overview.mdx b/packages/docs/pages/docs/overview.mdx index 10e433b8601..6074aa3352b 100644 --- a/packages/docs/pages/docs/overview.mdx +++ b/packages/docs/pages/docs/overview.mdx @@ -15,7 +15,9 @@ Qwik is a new kind of web framework that can deliver instant loading web applica Qwik Diagram ## Does page speed really matter? diff --git a/packages/eslint-plugin-qwik/package.json b/packages/eslint-plugin-qwik/package.json index ac957c82dee..d82baa44b43 100644 --- a/packages/eslint-plugin-qwik/package.json +++ b/packages/eslint-plugin-qwik/package.json @@ -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", diff --git a/packages/qwik-city/package.json b/packages/qwik-city/package.json index b3952e71e2d..103d5ff9a6f 100644 --- a/packages/qwik-city/package.json +++ b/packages/qwik-city/package.json @@ -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", diff --git a/packages/qwik-city/src/runtime/api.md b/packages/qwik-city/src/runtime/api.md index b910eb0a3c1..6a371b59cde 100644 --- a/packages/qwik-city/src/runtime/api.md +++ b/packages/qwik-city/src/runtime/api.md @@ -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) diff --git a/packages/qwik-city/src/runtime/page.ts b/packages/qwik-city/src/runtime/page.ts index 6637f6c7192..04c0bb862e5 100644 --- a/packages/qwik-city/src/runtime/page.ts +++ b/packages/qwik-city/src/runtime/page.ts @@ -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'; @@ -18,7 +19,7 @@ export const QwikCityContext = createContext('qwikcity-page'); */ export const useQwikCity = () => { const href = useLocation().href; - const page = useStore({} as any); + const page: PageHandler = {} as any; useWaitOn( loadPage(href).then((loaded) => { if (loaded) { @@ -32,6 +33,7 @@ export const useQwikCity = () => { content: noSerialize(loaded.content), layout: noSerialize(loaded.layout), }); + immutable(page); } }) ); diff --git a/packages/qwik-city/src/runtime/types.ts b/packages/qwik-city/src/runtime/types.ts index b331b5d2bc7..e1b222c1d16 100644 --- a/packages/qwik-city/src/runtime/types.ts +++ b/packages/qwik-city/src/runtime/types.ts @@ -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; } /** diff --git a/packages/qwik/package.json b/packages/qwik/package.json index af6b3741a44..f0cd760d0dc 100644 --- a/packages/qwik/package.json +++ b/packages/qwik/package.json @@ -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", diff --git a/packages/qwik/src/server/prefetch-strategy.ts b/packages/qwik/src/server/prefetch-strategy.ts index 01047028475..f45df399b57 100644 --- a/packages/qwik/src/server/prefetch-strategy.ts +++ b/packages/qwik/src/server/prefetch-strategy.ts @@ -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); - } - } } } } diff --git a/yarn.lock b/yarn.lock index 15abbbf8cc4..cc6ed54f756 100644 --- a/yarn.lock +++ b/yarn.lock @@ -409,7 +409,7 @@ __metadata: languageName: node linkType: hard -"@builder.io/qwik-city@0.0.6, @builder.io/qwik-city@workspace:packages/qwik-city": +"@builder.io/qwik-city@0.0.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: @@ -450,7 +450,14 @@ __metadata: languageName: node linkType: hard -"@builder.io/qwik@0.0.20, @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 @@ -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