Skip to content

Commit

Permalink
feat: streaming ssr + rsc
Browse files Browse the repository at this point in the history
  • Loading branch information
GiveMe-A-Name committed Sep 6, 2024
1 parent 6631d6b commit 7a3c0a6
Show file tree
Hide file tree
Showing 23 changed files with 648 additions and 41 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,5 @@
"[javascript]": {
"editor.defaultFormatter": "biomejs.biome"
},
"todo-tree.tree.disableCompactFolders": true,
}
4 changes: 2 additions & 2 deletions packages/runtime/plugin-runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@
"@types/node": "^14",
"@types/react-side-effect": "^1.1.1",
"jest": "^29",
"react": "^18",
"react-dom": "^18",
"react": "18.3.0-canary-8039e6d0b-20231026",
"react-dom": "18.3.0-canary-8039e6d0b-20231026",
"ts-jest": "^29.1.0",
"typescript": "^5",
"webpack": "^5.93.0"
Expand Down
4 changes: 3 additions & 1 deletion packages/runtime/plugin-runtime/src/cli/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ export const index = ({
customBootstrap?: string | false;
mountId?: string;
}) =>
`import '@${metaName}/runtime/registry/${entryName}';
// TODO: remove this
`
${genRenderCode({
srcDirectory,
internalSrcAlias,
Expand Down Expand Up @@ -166,6 +167,7 @@ import App from '${
customEntry
? entry
.replace('entry.tsx', 'App')
.replace('entry.jsx', 'App')
.replace(srcDirectory, internalSrcAlias)
: entry.replace(srcDirectory, internalSrcAlias).replace('.tsx', ''),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export function buildShellAfterTemplate(
async function injectJs(template: string, entryName: string, nonce?: string) {
const { routeManifest } = runtimeContext;
const { routeAssets } = routeManifest;
const asyncEntry = routeAssets[`async-${entryName}`];
const asyncEntry = routeAssets?.[`async-${entryName}`];
if (asyncEntry) {
const { assets } = asyncEntry;
const jsChunkStr = assets
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ export const createReadableStreamFromElement: CreateReadableStreamFromElement =
* So we use the `SHELL_STREAM_END_MARK` to mark the shell content' tail.
*/
let concatedChunk = chunkVec.join('');
if (concatedChunk.includes(ESCAPED_SHELL_STREAM_END_MARK)) {
concatedChunk = concatedChunk.replace(
ESCAPED_SHELL_STREAM_END_MARK,
'',
);

shellChunkStatus = ShellChunkStatus.FINISH;
this.push(`${shellBefore}${concatedChunk}${shellAfter}`);
}
// if (concatedChunk.includes(ESCAPED_SHELL_STREAM_END_MARK)) {
concatedChunk = concatedChunk.replace(
ESCAPED_SHELL_STREAM_END_MARK,
'',
);

shellChunkStatus = ShellChunkStatus.FINISH;
this.push(`${shellBefore}${concatedChunk}${shellAfter}`);
// }
} else {
this.push(chunk);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/solutions/app-tools/src/plugins/analyze/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export default ({

builder.onAfterBuild(async ({ stats }) => {
const hookRunners = api.useHookRunners();
await hookRunners.afterBuild({ stats });
await hookRunners.afterBuild({ stats: stats as any });
await emitResolvedConfig(appContext.appDirectory, normalizedConfig);
});

Expand Down
156 changes: 129 additions & 27 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions tests/integration/basic-rsc-ssr/.browserslistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
chrome >= 51
edge >= 15
firefox >= 54
safari >= 10
ios_saf >= 10
Loading

0 comments on commit 7a3c0a6

Please sign in to comment.