-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
feat: rsc to ssr #6682
base: feat-rsc
Are you sure you want to change the base?
feat: rsc to ssr #6682
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## feat-rsc #6682 +/- ##
============================================
- Coverage 77.93% 77.58% -0.36%
============================================
Files 223 225 +2
Lines 19668 19782 +114
Branches 2461 2466 +5
============================================
+ Hits 15329 15348 +19
- Misses 4307 4402 +95
Partials 32 32 ☔ View full report in Codecov by Sentry. |
@@ -112,7 +117,7 @@ const transformPipe = (options: PluginOptions = {}): Plugin => { | |||
let sourceMap = null; | |||
|
|||
if (plugin.load && (!loadInclude || loadInclude?.(id))) { | |||
const result = await plugin.load.call(pluginContext, id); | |||
const result = await plugin.load.call(pluginContext, id, args.namespace); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
希望在插件的 load 中只处理 resolved 的 path,所以透传了 namespace 进行标记,看看是否有更好的方式。
fd7993b
to
f514221
Compare
f514221
to
fd7993b
Compare
fd7993b
to
e85d65f
Compare
await new Promise<any>((resolve) => { | ||
setTimeout(() => resolve(null), 3000); | ||
}); | ||
|
||
return fakeData; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这段代码不会执行到的了,可去掉
render() { | ||
if (this.state.hasError) { | ||
// @ts-ignore | ||
const ClientComments = lazy(() => import('./CommentsWithServerError')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ClientComments -> CommentsWithServerError
|
||
const CSSRegex = /\.(css|sass|scss)$/; | ||
|
||
Object.keys(ssrManifest).map(router => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
有一些 lint 的问题
if (modules[id] || CSSRegex.test(id)) return; | ||
modules[id] = true; | ||
index++; | ||
imports.push(`import * as component_${index} from "(rsc)${id}";`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(rsc)
感觉可以换成 rsc:
,然后注释下后面会替换掉
name: 'esbuild-rsc-loader', | ||
setup(build: PluginBuild) { | ||
build.onResolve({ filter: /react-ssr-module-mapping.json$/ }, (args) => { | ||
if (args.path === 'virtual-rsc-module:react-ssr-module-mapping.json') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个 mapping 是有什么用吗?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个是 Server 端渲染 RSC 结果到 SSR 时,需要用到 Client Components 的 mapping。会根据这份产物加载对应的 Client Component 的 Server 端 Bundle,然后渲染
plugins: [ | ||
serverComponent && transformRSCDirectivePlugin(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
插件命名上,建议是 RemoveUseClientDirectivePlugin
实现思路