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 Feat: support streaming ssr + rsc #6183

Open
wants to merge 3 commits into
base: feat-next-wym
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
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: 2 additions & 2 deletions packages/runtime/plugin-runtime/src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { generateCode } from './code';
import { builderPluginAlias } from './alias';

export { isRuntimeEntry } from './entry';
export { statePlugin, ssrPlugin, routerPlugin, documentPlugin };
export { statePlugin, ssrPlugin, routerPlugin };
export const runtimePlugin = (params?: {
plugins?: CliPlugin<AppTools>[];
}): CliPlugin<AppTools> => ({
Expand All @@ -32,7 +32,7 @@ export const runtimePlugin = (params?: {
ssrPlugin(),
routerPlugin(),
statePlugin(),
documentPlugin(),
// documentPlugin(),
],
setup: api => {
return {
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
2 changes: 1 addition & 1 deletion packages/toolkit/utils/src/cli/is/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export const isReact18 = (cwd: string = process.cwd()) => {
return false;
}

return semver.satisfies(semver.minVersion(deps.react)!, '>=18.0.0');
return semver.gte(semver.minVersion(deps.react)!, '18.0.0');
};

/**
Expand Down
Loading