Skip to content

Commit a82d4fa

Browse files
committed
doc: Lazy loading example
1 parent 3baadb0 commit a82d4fa

File tree

5 files changed

+19
-4
lines changed

5 files changed

+19
-4
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"package": "svelte-package",
2121
"lint": "concurrently -c \"#c596c7\",\"#676778\",\"#3074c0\",\"#7c7cea\" --kill-others-on-fail \"npm:lint:*\"",
2222
"lint:prettier": "prettier --check --loglevel=warn \"src/**/*.svelte\"",
23-
"lint:svelte-check": "svelte-check --fail-on-warnings --fail-on-hints --ignore build,package,src/tests",
23+
"lint:svelte-check": "svelte-check --fail-on-warnings --fail-on-hints",
2424
"lint:tsc": "tsc --noEmit",
2525
"lint:eslint": "eslint --ext=js,ts,svelte --max-warnings=0 src",
2626
"format": "prettier --write . && eslint --ext=js,ts,svelte --fix src",
@@ -41,7 +41,7 @@
4141
],
4242
"*.svelte": [
4343
"eslint --max-warnings 0 --no-ignore",
44-
"svelte-check --fail-on-warnings --fail-on-hints --ignore build,package,src/tests",
44+
"svelte-check --fail-on-warnings --fail-on-hints",
4545
"prettier --check"
4646
]
4747
},

src/lib/reactify.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ export type SvelteConstructor<Props = any, Events = any, Slot = any> = {
1717
export default function reactify<P = any, E = any>(
1818
SvelteComponent: SvelteConstructor<P, E>
1919
): React.FunctionComponent<
20-
P & SvelteEventHandlers<E> & { children?: React.ReactNode }
20+
| (P & SvelteEventHandlers<E> & { children?: React.ReactNode })
21+
| { children?: React.ReactNode }
2122
> {
2223
const { name } = SvelteComponent as any;
2324
const named = {

src/routes/+page.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@
1212
<li><a href="/hooks">Using hooks</a></li>
1313

1414
<li><a href="/react-router/home">react-router</a></li>
15+
<li><a href="/lazy">react lazy</a></li>
1516
</ul>

src/routes/lazy/+page.svelte

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<script lang="ts">
2+
import { browser } from "$app/environment";
3+
import { used } from "$lib";
4+
import { lazy, Suspense } from "react";
5+
6+
const Counter = lazy(() => import("../../demo/react-components/Counter"));
7+
used(Counter, Suspense);
8+
</script>
9+
10+
{#if browser}
11+
<react:Counter />
12+
{/if}

tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@
1515
"strict": true,
1616
"noEmit": true,
1717
"jsx": "preserve"
18-
}
18+
},
19+
"exclude": ["build", "package", "src/tests"]
1920
}

0 commit comments

Comments
 (0)