Skip to content

Commit

Permalink
chore: remove switch of firstchunk (#6638)
Browse files Browse the repository at this point in the history
* chore: remove switch of firstchunk

* chore: add changeset

* feat: add export and modify example
  • Loading branch information
answershuto authored Nov 16, 2023
1 parent a0df6fa commit 5d85418
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 15 deletions.
5 changes: 5 additions & 0 deletions .changeset/popular-shirts-explain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@ice/runtime': patch
---

chore: remove switch of cache first chunk
3 changes: 0 additions & 3 deletions examples/with-first-chunk-cache-ssr/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,4 @@ export default defineAppConfig({
app: {
rootId: 'app',
},
cache: {
firstChunk: true,
},
});
3 changes: 2 additions & 1 deletion examples/with-first-chunk-cache-ssr/src/document.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Meta, Title, Links, Main, Scripts } from 'ice';
import { Meta, Title, Links, Main, Scripts, FirstChunkCache } from 'ice';

function Document() {
return (
Expand All @@ -13,6 +13,7 @@ function Document() {
</head>
<body>
<Main />
<FirstChunkCache />
<Scripts async />
</body>
</html>
Expand Down
2 changes: 2 additions & 0 deletions packages/ice/src/plugins/web/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const plugin: Plugin = () => ({
'Title',
'Links',
'Scripts',
'FirstChunkCache',
'Data',
'Main',
'usePageAssets',
Expand All @@ -24,6 +25,7 @@ const plugin: Plugin = () => ({
'TitleType',
'LinksType',
'ScriptsType',
'FirstChunkCacheType',
'DataType',
'MainType',
],
Expand Down
11 changes: 3 additions & 8 deletions packages/runtime/src/Document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,14 +208,9 @@ export const Main: MainType = (props: React.HTMLAttributes<HTMLDivElement>) => {
const { appConfig } = useAppContext();

return (
<>
<div id={appConfig.app.rootId} {...props}>
{main}
</div>
{
appConfig.cache?.firstChunk && <FirstChunkCache />
}
</>
<div id={appConfig.app.rootId} {...props}>
{main}
</div>
);
};

Expand Down
2 changes: 2 additions & 0 deletions packages/runtime/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
Title,
Links,
Scripts,
FirstChunkCache,
Main,
Data,
usePageAssets,
Expand Down Expand Up @@ -112,6 +113,7 @@ export {
Title,
Links,
Scripts,
FirstChunkCache,
Data,
Main,
usePageAssets,
Expand Down
3 changes: 0 additions & 3 deletions packages/runtime/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ export interface AppConfig {
basename?: string;
initialEntries?: InitialEntry[];
};
cache?: {
firstChunk?: boolean;
};
}

export interface RoutesConfig {
Expand Down

0 comments on commit 5d85418

Please sign in to comment.