-
-
Notifications
You must be signed in to change notification settings - Fork 834
feat: builtin react server component #12012
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
Merged
Merged
Changes from all commits
Commits
Show all changes
99 commits
Select commit
Hold shift + click to select a range
4a4505b
react_server_components transform
SyMind 31c656c
Merge remote-tracking branch 'origin' into react-server-component
SyMind 62ce9de
fix: ReactServerComponents
SyMind b3b4fcb
ReactServerComponentPlugin
SyMind 1b0c818
chore: merge origin main
SyMind c87018b
Merge remote-tracking branch 'origin' into react-server-component
SyMind 82925c0
fix: rspack_loader_swc Wtf8Atom
SyMind 58288ed
feat: ReactServerComponentPlugin
SyMind ac7e626
feat: ServerEntryModules
SyMind 107db20
exports_info
SyMind 99d57f3
temp
SyMind be58a45
chore: merge origin main
SyMind 4a8c912
feat: import with layer
SyMind e1015a8
fix: before pass
SyMind 208cc52
export ReactServerComponentsPlugin
SyMind af4d829
ServerEntries
SyMind a9253fd
feat: client_entry_loader
SyMind a2b0457
feat: client compiler
SyMind 2e3accd
feat: traverse_modules
SyMind fb39548
feat: ClientReferenceManifestPlugin
SyMind 8e5c091
feat: react_server_components layer
SyMind 95a7401
fix ReactClientPlugin
SyMind 68ff4c2
fix: ClientReferenceManifestPlugin
SyMind cedca6d
refactor: rename to ReactServerPlugin
SyMind 5b0cc98
remove eager
SyMind 4c953cb
feat: collect entry css files
SyMind 137db08
feat: use server-entry
SyMind b3b67bb
server actions transform
SyMind 31f38e9
feat: action_entry_loader
SyMind ed7be7f
collect server_actions
SyMind 2c0904e
temp
SyMind 5757e63
manifest-loader
SyMind 3d623f7
RscManifestRuntimeModule
SyMind 8d630e5
fix: build_server_consumer_module_map
SyMind 939e4f5
fix: entry_css_files
SyMind 7b6e552
feat: record_entry_js_files
SyMind cb2d8ae
refactor: entry_css_files
SyMind 6503ea7
fix: entry js files and entry css files should concat prefix
SyMind 07671a3
remove unused code
SyMind 538a9d6
chore: rename loader and plugin
SyMind 1816837
fix: Coordinator
SyMind f9da86a
fix: entry js files prevent hot-module files from being included
SyMind 5682885
clear PLUGIN_STATE_BY_COMPILER_ID
SyMind 28444af
feat: add_include client action
SyMind a4e78f3
feat: prev_server_component_hashs
SyMind 79bceac
fix: client compiler not rebuild right
SyMind 4017bc1
export RSC_LAYERS_NAMES
SyMind 32a395d
fix: remove import with layer
SyMind 3edfdb9
refactor: rsc_pass
SyMind 6350970
refactor: rsc_meta
SyMind 2486463
refactor: to_module_ref
SyMind c3bbc5a
chore: merge origin main
SyMind 7d7644c
fix: cargo clippy
SyMind 57b70b9
fix: lint and spelling
SyMind ecf3f75
api changed
SyMind 48927fb
refactor: use get_module_resource
SyMind 5f38eb6
fix: ts type
SyMind 4941195
fix: compiler watching
SyMind bc09b12
feat: check should_inject_ssr_modules
SyMind 9a46804
fix: only invalidate client after proxying client watching
SyMind 5e52ec1
fix: client module chunks should exclude hot module replacement js
SyMind 2413e2d
chore: rename coordinator mod
SyMind 233e1b2
fix: collect_component_info_from_entry_denendency
SyMind 53525da
fix: panic in create_client_entries
SyMind 151c4ae
fix: browser action
SyMind a79dfbd
rm ACTION_BROWSER layer
SyMind 7878acb
fix: use atomic ref
SyMind b4aa13e
refactor client plugin
SyMind b303a91
fix: should handle compile failed
SyMind 09dd289
chore: rm unused print
SyMind 3576c7d
fix: use server-entry mix use client
SyMind c95987a
feat: ensureServerActions
SyMind d07a6c5
fix: RSC_HOT_RELOADER
SyMind 0bd447a
refactor: create_client_entries
SyMind 6e3e3b1
fix: encryptActionBoundArgs and decryptActionBoundArgs
SyMind a1af972
fix: should collect entry css files in after_process_assets hook
SyMind 26c11d2
fix: with concat module
SyMind aa18a19
chore(deps): update patch npm dependencies (#12647)
renovate[bot] ece0fee
chore(deps): update patch crates (#12646)
renovate[bot] edce5bd
chore: run ci/eco-ci/eco-benchmark on v2 branch (#12650)
LingyuCoder 44a7564
fix: report error when access module_graph in loader (#12639)
hardfist 25a4021
feat(rstest): add preserveNewUrl option to keep new URL untouched (#1…
fi3ework d424733
fix(lint): enable @typescript-eslint/await-thenable rule (#12644)
tt-a1i a5c4032
chore: merge origin main
SyMind ba1ce5f
fix: cargo clippy
SyMind c5ba0b6
refactor: rm RSC_HOT_RELOADER runtime module
SyMind d3db545
chore: merge origin v2
SyMind ee7bda8
fix: lint check
SyMind 7224564
refactor: rename RscPluginLayers
SyMind 965a498
warp rsc in namespace
SyMind 0b48f4e
fix: rsc client plugin
SyMind 0e85d4d
fix: cargo fmt
SyMind ac05ef7
add next.js Copyright
SyMind 3c5ea37
fix: user can change fileDependencies in done hook
SyMind 40268c3
chore: merge origin v2
SyMind 148860c
chore: add comments
SyMind f3303ce
fix: cargo fmt
SyMind 0cfbe8e
rm ustr dependencies
SyMind 4276a07
chore: merge origin main
SyMind File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| use std::sync::Arc; | ||
|
|
||
| use futures::future::BoxFuture; | ||
| use napi::{ | ||
| Env, Status, | ||
| bindgen_prelude::{ | ||
| ClassInstance, Either3, External, ExternalRef, FromNapiValue, Function, JsObjectValue, Null, | ||
| Object, Promise, Reference, Undefined, WeakReference, | ||
| }, | ||
| threadsafe_function::ThreadsafeFunction, | ||
| }; | ||
| use once_cell::unsync::OnceCell; | ||
| use rspack_core::{Compiler, CompilerId}; | ||
| use rspack_error::ToStringResultToRspackResultExt; | ||
| use rspack_plugin_rsc::{Coordinator, RscClientPluginOptions, RscServerPluginOptions}; | ||
|
|
||
| use crate::JsCompiler; | ||
|
|
||
| type InvalidateTsFn = Arc<ThreadsafeFunction<(), (), (), Status, false, true, 0>>; | ||
|
|
||
| #[napi] | ||
| pub struct JsCoordinator { | ||
| i: Arc<Coordinator>, | ||
| } | ||
|
|
||
| #[napi] | ||
| impl JsCoordinator { | ||
| #[napi(constructor)] | ||
| pub fn new( | ||
| get_server_compiler_id_js_fn: Function<'static, (), &'static External<CompilerId>>, | ||
| ) -> napi::Result<Self> { | ||
| let get_server_compiler_id = { | ||
| let ts_fn = Arc::new( | ||
| get_server_compiler_id_js_fn | ||
| .build_threadsafe_function::<()>() | ||
| .callee_handled::<false>() | ||
| .max_queue_size::<0>() | ||
| .weak::<true>() | ||
| .build()?, | ||
| ); | ||
| Box::new( | ||
| move || -> BoxFuture<'static, rspack_error::Result<CompilerId>> { | ||
| let ts_fn = ts_fn.clone(); | ||
| Box::pin(async move { | ||
| let external = ts_fn.call_async(()).await.to_rspack_result()?; | ||
| Ok(**external) | ||
| }) | ||
| }, | ||
| ) | ||
| }; | ||
|
|
||
| Ok(Self { | ||
| i: Arc::new(Coordinator::new(get_server_compiler_id)), | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| impl From<&JsCoordinator> for Arc<Coordinator> { | ||
| fn from(value: &JsCoordinator) -> Self { | ||
| value.i.clone() | ||
| } | ||
| } | ||
|
|
||
| #[napi(object, object_to_js = false)] | ||
| pub struct JsRscClientPluginOptions<'a> { | ||
| pub coordinator: ClassInstance<'a, JsCoordinator>, | ||
| } | ||
|
|
||
| impl From<&JsRscClientPluginOptions<'_>> for RscClientPluginOptions { | ||
| fn from(value: &JsRscClientPluginOptions) -> Self { | ||
| Self { | ||
| coordinator: value.coordinator.i.clone(), | ||
| } | ||
| } | ||
| } | ||
|
|
||
| #[napi(object, object_to_js = false)] | ||
| pub struct JsRscServerPluginOptions<'a> { | ||
| pub coordinator: ClassInstance<'a, JsCoordinator>, | ||
| pub on_server_component_changes: Option<Either3<Function<'static, (), ()>, Undefined, Null>>, | ||
| } | ||
|
|
||
| impl TryFrom<&JsRscServerPluginOptions<'_>> for RscServerPluginOptions { | ||
| type Error = napi::Error; | ||
|
|
||
| fn try_from(value: &JsRscServerPluginOptions) -> napi::Result<Self> { | ||
| let on_server_component_changes: Option< | ||
| Box<dyn Fn() -> BoxFuture<'static, rspack_error::Result<()>> + Sync + Send>, | ||
| > = match value.on_server_component_changes { | ||
| Some(Either3::A(js_fn)) => { | ||
| let ts_fn = Arc::new( | ||
| js_fn | ||
| .build_threadsafe_function::<()>() | ||
| .callee_handled::<false>() | ||
| .max_queue_size::<0>() | ||
| .weak::<true>() | ||
| .build()?, | ||
| ); | ||
| Some(Box::new( | ||
| move || -> BoxFuture<'static, rspack_error::Result<()>> { | ||
| let ts_fn = ts_fn.clone(); | ||
| Box::pin(async move { ts_fn.call_async(()).await.to_rspack_result() }) | ||
| }, | ||
| )) | ||
| } | ||
| _ => None, | ||
| }; | ||
|
|
||
| Ok(Self { | ||
| coordinator: value.coordinator.i.clone(), | ||
| on_server_component_changes, | ||
| }) | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.