@@ -23,14 +23,55 @@ export default defineEntries({
23
23
return renderHtml ({ App: <App name = " Waku" /> }, <Slot id = " App" />, ' ' );
24
24
}
25
25
},
26
- getBuildConfig : async () => [{ pathSpec: [], entries: [{ rscPath: ' ' }] }] ,
26
+ handleBuild : () => null ,
27
27
});
28
28
```
29
29
30
30
Tips for experimenting:
31
31
32
+ - Object keys like ` App ` are called RSC ID.
32
33
- ` input.type === 'custom' ` condition can be omitted if you don't need SSR.
33
- - ` getBuildConfig ` can return ` [] ` if you don't need to build anything.
34
+
35
+ #### ` handleBuild `
36
+
37
+ The ` handleBuild ` function is to produce a build for production.
38
+ It has to return AsyncIterable of build instructions.
39
+
40
+ ``` tsx
41
+ handleBuild : ({
42
+ renderRsc ,
43
+ renderHtml ,
44
+ rscPath2pathname ,
45
+ unstable_generatePrefetchCode ,
46
+ }) =>
47
+ createAsyncIterable (async () => {
48
+ const moduleIds = new Set <string >();
49
+ const generateHtmlHead = () =>
50
+ ` <script type="module" async>${unstable_generatePrefetchCode (
51
+ [' ' ],
52
+ moduleIds ,
53
+ )}</script> ` ;
54
+ const tasks = [
55
+ async () => ({
56
+ type: ' file' as const ,
57
+ pathname: rscPath2pathname (' ' ),
58
+ body: renderRsc (
59
+ { App: <App name = " Waku" /> },
60
+ { moduleIdCallback : (id ) => moduleIds .add (id ) },
61
+ ),
62
+ }),
63
+ async () => ({
64
+ type: ' file' as const ,
65
+ pathname: ' /' ,
66
+ body: renderHtml ({ App: <App name = " Waku" /> }, <Slot id = " App" />, {
67
+ rscPath: ' ' ,
68
+ htmlHead: generateHtmlHead (),
69
+ }).then (({ body }) => body ),
70
+ }),
71
+ ];
72
+ return tasks ;
73
+ }),
74
+ ```
34
75
35
76
### Client API
36
77
@@ -72,3 +113,4 @@ const Component = () => {
72
113
- [ ../examples/31_minimal] (Minimal example)
73
114
- [ ../examples/34_functions] (With server functions)
74
115
- [ ../examples/39_api] (With custom API endpoints)
116
+ - [ ../examples/51_spa] (Fully client components)
0 commit comments