Skip to content

Commit 3ef70cc

Browse files
committed
Merge remote-tracking branch 'upstream/main' into update-all-deps-minor
2 parents a3d9fff + 7da9d35 commit 3ef70cc

File tree

8 files changed

+672
-846
lines changed

8 files changed

+672
-846
lines changed

.vscode/launch.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,18 @@
4040
"program": "${workspaceFolder}/packages/docs/node_modules/vite/bin/vite.js",
4141
"args": ["build", "-c", "adapters/cloudflare-pages/vite.config.mts"]
4242
},
43+
{
44+
"type": "node",
45+
"name": "preloader-test build.client",
46+
"request": "launch",
47+
"runtimeExecutable": "pnpm",
48+
"runtimeArgs": [
49+
"run",
50+
"build.client"
51+
],
52+
"skipFiles": ["<node_internals>/**"],
53+
"cwd": "${workspaceFolder}/starters/apps/preloader-test"
54+
},
4355
{
4456
"type": "node",
4557
"name": "e2e.test",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@
132132
"cross-spawn": "7.0.6",
133133
"csstype": "3.1.3",
134134
"dotenv": "16.5.0",
135-
"esbuild": "0.20.2",
135+
"esbuild": "0.25.4",
136136
"eslint": "9.25.1",
137137
"eslint-plugin-no-only-tests": "3.3.0",
138138
"eslint-plugin-qwik": "workspace:^",

packages/docs/src/components/sidebar/sidebar.tsx

Lines changed: 20 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,11 @@
1-
import {
2-
component$,
3-
sync$,
4-
useComputed$,
5-
useContext,
6-
useOnDocument,
7-
useStyles$,
8-
} from '@builder.io/qwik';
9-
import { server$, useContent, useLocation, type ContentMenu } from '@builder.io/qwik-city';
1+
import { component$, sync$, useContext, useOnDocument, useStyles$ } from '@builder.io/qwik';
2+
import { type ContentMenu, useContent, useLocation, routeLoader$ } from '@builder.io/qwik-city';
103
import { GlobalStore } from '../../context';
114
import { CloseIcon } from '../svgs/close-icon';
125
import styles from './sidebar.css?inline';
136

14-
let markdownItems: MarkdownItems | undefined;
15-
let markdownItemsPromise: Promise<MarkdownItems> | undefined;
16-
export const getMarkdownItems = server$(() => {
17-
if (markdownItems) {
18-
return markdownItems;
19-
}
20-
21-
markdownItemsPromise ||= Promise.all(
7+
export const useMarkdownItems = routeLoader$(async () => {
8+
const rawData = await Promise.all(
229
Object.entries(import.meta.glob<{ frontmatter?: MDX }>('../../routes/**/*.{md,mdx}')).map(
2310
async ([k, v]) => {
2411
return [
@@ -33,22 +20,20 @@ export const getMarkdownItems = server$(() => {
3320
] as const;
3421
}
3522
)
36-
).then((rawData) => {
37-
markdownItems = {};
38-
rawData.map(([k, v]) => {
39-
if (v.frontmatter?.updated_at) {
40-
markdownItems![k] = {
41-
title: v.frontmatter.title,
42-
contributors: v.frontmatter.contributors,
43-
created_at: v.frontmatter.created_at,
44-
updated_at: v.frontmatter.updated_at,
45-
};
46-
}
47-
});
48-
49-
return markdownItems;
23+
);
24+
const markdownItems: MarkdownItems = {};
25+
rawData.map(([k, v]) => {
26+
if (v.frontmatter?.updated_at) {
27+
markdownItems[k] = {
28+
title: v.frontmatter.title,
29+
contributors: v.frontmatter.contributors,
30+
created_at: v.frontmatter.created_at,
31+
updated_at: v.frontmatter.updated_at,
32+
};
33+
}
5034
});
51-
return markdownItemsPromise;
35+
36+
return markdownItems;
5237
});
5338

5439
type MarkdownItems = Record<string, MDX>;
@@ -79,7 +64,7 @@ export const SideBar = component$((props: { allOpen?: boolean }) => {
7964
const globalStore = useContext(GlobalStore);
8065
const { menu } = useContent();
8166
const { url } = useLocation();
82-
const markdownItems = useComputed$(() => getMarkdownItems());
67+
const markdownItems = useMarkdownItems();
8368
const allOpen = url.pathname.startsWith('/qwikcity/') || props.allOpen;
8469

8570
useOnDocument(
@@ -93,7 +78,7 @@ export const SideBar = component$((props: { allOpen?: boolean }) => {
9378
el.scrollTop = savedScroll;
9479
el.style.visibility = 'visible';
9580
}
96-
} catch {
81+
} catch (err) {
9782
//
9883
}
9984
})
@@ -118,7 +103,7 @@ export const SideBar = component$((props: { allOpen?: boolean }) => {
118103
try {
119104
const scrollTop = document.getElementById('qwik-sidebar')!.scrollTop;
120105
sessionStorage.setItem('qwik-sidebar', String(scrollTop));
121-
} catch {
106+
} catch (err) {
122107
//
123108
}
124109
})}

packages/docs/src/routes/community/layout.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import { OnThisPage } from '../../components/on-this-page/on-this-page';
66
import { ContentNav } from '../../components/content-nav/content-nav';
77
import styles from '../docs/docs.css?inline';
88

9+
export { useMarkdownItems } from '../../components/sidebar/sidebar';
10+
911
export default component$(() => {
1012
useStyles$(styles);
1113

packages/docs/src/routes/docs/layout.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import { createBreadcrumbs, SideBar } from '../../components/sidebar/sidebar';
99
import { GlobalStore } from '../../context';
1010
import styles from './docs.css?inline';
1111

12+
export { useMarkdownItems } from '../../components/sidebar/sidebar';
13+
1214
export default component$(() => {
1315
useStyles$(styles);
1416
const loc = useLocation();

packages/qwik-city/src/buildtime/vite/get-route-imports.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,12 @@ export function getRouteImports(routes: BuildRoute[], manifest: QwikManifest) {
2626
for (const bundleName of Object.keys(manifest.bundles)) {
2727
const bundle = manifest.bundles[bundleName];
2828
if (bundle.origins?.some((s) => s.endsWith(QWIK_CITY_PLAN_ID))) {
29-
// Don't consider the city plan for preloading
30-
// we keep imports because something might be bundled with it
31-
result[bundleName] = { imports: bundle.imports, dynamicImports: [] };
29+
result[bundleName] = {
30+
...bundle,
31+
dynamicImports: bundle.dynamicImports?.filter((d) =>
32+
manifest.bundles[d].origins?.some((s) => s.endsWith('menu.md'))
33+
),
34+
};
3235
break;
3336
}
3437
}

packages/qwik-city/src/buildtime/vite/get-route-imports.unit.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,12 @@ describe('modifyBundleGraph', () => {
6464
],
6565
},
6666
"q-city-plan.js": {
67-
"dynamicImports": [],
68-
"imports": undefined,
67+
"dynamicImports": undefined,
68+
"origins": [
69+
"@qwik-city-plan",
70+
],
71+
"size": 0,
72+
"total": 0,
6973
},
7074
}
7175
`);

0 commit comments

Comments
 (0)