Skip to content
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

WIP: Reduce bundle size #906

Draft
wants to merge 30 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
cc816e2
Reduce bundle size
brenelz Sep 28, 2024
accb27a
Merge branch 'main' into reduce-bundle-size
kodiakhq[bot] Sep 28, 2024
256f057
Merge branch 'main' into reduce-bundle-size
kodiakhq[bot] Sep 29, 2024
ea51352
Merge branch 'main' into reduce-bundle-size
kodiakhq[bot] Oct 3, 2024
11e4bd7
Merge branch 'main' into reduce-bundle-size
kodiakhq[bot] Oct 4, 2024
b163a5d
Merge branch 'main' into reduce-bundle-size
kodiakhq[bot] Oct 4, 2024
2e7d38d
Merge branch 'main' into reduce-bundle-size
kodiakhq[bot] Oct 7, 2024
b8a72ca
Merge branch 'main' into reduce-bundle-size
kodiakhq[bot] Oct 8, 2024
412bf95
Merge branch 'main' into reduce-bundle-size
kodiakhq[bot] Oct 9, 2024
fc2977a
Merge branch 'main' into reduce-bundle-size
kodiakhq[bot] Oct 9, 2024
a86c6c0
Merge branch 'main' into reduce-bundle-size
kodiakhq[bot] Oct 13, 2024
8bcf6e9
Merge branch 'main' into reduce-bundle-size
kodiakhq[bot] Oct 14, 2024
b1b1982
Merge branch 'main' into reduce-bundle-size
kodiakhq[bot] Oct 15, 2024
cfedaea
Merge branch 'main' into reduce-bundle-size
kodiakhq[bot] Oct 16, 2024
4d0cfc7
Merge branch 'main' into reduce-bundle-size
kodiakhq[bot] Oct 17, 2024
edbc804
Merge branch 'main' into reduce-bundle-size
kodiakhq[bot] Oct 24, 2024
c51fb3d
Merge branch 'main' into reduce-bundle-size
kodiakhq[bot] Oct 24, 2024
191ba63
Merge branch 'main' into reduce-bundle-size
kodiakhq[bot] Oct 24, 2024
9b98b5b
Merge branch 'main' into reduce-bundle-size
kodiakhq[bot] Oct 24, 2024
9a6e244
Merge branch 'main' into reduce-bundle-size
kodiakhq[bot] Oct 24, 2024
f4840e6
Merge branch 'main' into reduce-bundle-size
kodiakhq[bot] Oct 30, 2024
9826da5
Merge branch 'main' into reduce-bundle-size
kodiakhq[bot] Oct 30, 2024
be83113
Merge branch 'main' into reduce-bundle-size
kodiakhq[bot] Oct 31, 2024
d14512c
Merge branch 'main' into reduce-bundle-size
kodiakhq[bot] Nov 3, 2024
7b96246
Merge branch 'main' into reduce-bundle-size
kodiakhq[bot] Nov 3, 2024
9cc0586
Merge branch 'main' into reduce-bundle-size
kodiakhq[bot] Nov 3, 2024
eb8821e
Merge branch 'main' into reduce-bundle-size
kodiakhq[bot] Nov 4, 2024
1734004
Merge branch 'main' into reduce-bundle-size
kodiakhq[bot] Nov 4, 2024
fb7a131
Merge branch 'main' into reduce-bundle-size
kodiakhq[bot] Nov 11, 2024
7b7025b
Merge branch 'main' into reduce-bundle-size
kodiakhq[bot] Nov 11, 2024
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
10 changes: 6 additions & 4 deletions src/ui/layout/hero-code-snippet.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

import { cache, createAsync } from "@solidjs/router";
import { codeToHtml } from "shiki";
import { createResource } from "solid-js";

export const counterTxt = `import { createSignal } from "solid-js";

Expand All @@ -17,16 +18,17 @@ function Counter() {

export const snippetLines = counterTxt.split("\n");

const renderCode = async () => {
const renderCode = cache(async () => {
"use server";
const code = counterTxt.trim();
return codeToHtml(code, {
lang: "tsx",
theme: "material-theme-ocean",
});
};
}, "render-code");

export default function CodeSnippet() {
const [code] = createResource(renderCode);
const code = createAsync(() => renderCode());

// eslint-disable-next-line solid/no-innerhtml
return <div innerHTML={code()} />;
Expand Down
12 changes: 4 additions & 8 deletions src/ui/layout/hero.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,10 @@ import {
createMemo,
} from "solid-js";
import { ButtonLink } from "../button-link";
import { clientOnly } from "@solidjs/start";
import { counterTxt, snippetLines } from "./hero-code-snippet";
import CodeSnippet, { counterTxt, snippetLines } from "./hero-code-snippet";
import { useLocation, useMatch } from "@solidjs/router";
import { useI18n } from "~/i18n/i18n-context";

const RenderedCode = clientOnly(() => import("./hero-code-snippet"));

const TrafficLightsIcon: Component<{ class: string }> = (props) => {
return (
<svg aria-hidden="true" viewBox="0 0 42 10" fill="none" {...props}>
Expand Down Expand Up @@ -109,16 +106,15 @@ export const Hero: Component = () => {
</Index>
</div>
<div
class={`flex overflow-x-auto px-4 min-h-[${
snippetLines.length + 5
}em] text-white custom-scrollbar`}
class={`flex overflow-x-auto px-4 min-h-[${snippetLines.length + 5
}em] text-white custom-scrollbar`}
>
<Suspense
fallback={
<pre class="text-slate-300">{counterTxt}</pre>
}
>
<RenderedCode />
<CodeSnippet />
</Suspense>
</div>
</div>
Expand Down
Loading