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] Hydrate components immediately after downloading chunks #1656

Merged
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
16078ef
hydrate the component immediately when loaded and registered
AbanoubGhadban Nov 18, 2024
2ceec94
auto register server components and immediately hydrate stores
AbanoubGhadban Dec 2, 2024
b1a886b
move react-server-dom-webpack.d.ts to types directory
AbanoubGhadban Dec 11, 2024
2c4fae3
ensure to initialize registered stores array before accessing
AbanoubGhadban Dec 18, 2024
c547b75
refactoring
AbanoubGhadban Dec 18, 2024
0bc967c
refactor registration callback into separate class
AbanoubGhadban Dec 18, 2024
78aaa28
make the early hydration compatible with turbopack, backward compatib…
AbanoubGhadban Dec 23, 2024
58fd819
pass rsc path to RSC Client Root and move the config to RORP
AbanoubGhadban Jan 13, 2025
e7c80c3
update min node version to 18
AbanoubGhadban Jan 26, 2025
d972901
export registerServerComponent as a separate entrypoint to avoid clie…
AbanoubGhadban Jan 26, 2025
c6b0e1f
linting
AbanoubGhadban Jan 27, 2025
0d8842b
Update webpack assets status checker to use server bundle configuration
AbanoubGhadban Jan 27, 2025
94131d9
Update webpack assets status checker to handle bundle file paths
AbanoubGhadban Jan 27, 2025
ba38c98
[WIP] handle errors happen in rsc payload (#1663)
AbanoubGhadban Jan 30, 2025
96d10ea
Empty commit to trigger new CI build
AbanoubGhadban Jan 30, 2025
fb12a56
Simplify build script for react-on-rails package
AbanoubGhadban Jan 30, 2025
be85e6b
Add logging to prepack and prepare npm scripts
AbanoubGhadban Jan 30, 2025
9b36013
Revert "Add logging to prepack and prepare npm scripts"
AbanoubGhadban Jan 30, 2025
402bd8f
Revert "Simplify build script for react-on-rails package"
AbanoubGhadban Jan 30, 2025
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
Prev Previous commit
Next Next commit
linting
AbanoubGhadban committed Jan 27, 2025
commit c6b0e1ff0fb04e0f6c002c0861862e154dd3ce42
3 changes: 2 additions & 1 deletion knip.ts
Original file line number Diff line number Diff line change
@@ -9,7 +9,8 @@ const config: KnipConfig = {
'node_package/src/ReactOnRails.node.ts!',
'node_package/src/ReactOnRailsRSC.ts!',
'node_package/src/RSCWebpackLoader.js!',
'node_package/src/registerServerComponent.js!',
'node_package/src/registerServerComponent.ts!',
'node_package/src/RSCClientRoot.ts!',
],
project: ['node_package/src/**/*.[jt]s!', 'node_package/tests/**/*.[jt]s'],
babel: {
5 changes: 3 additions & 2 deletions lib/react_on_rails/packs_generator.rb
Original file line number Diff line number Diff line change
@@ -44,7 +44,7 @@ def create_pack(file_path)
puts(Rainbow("Generated Packs: #{output_path}").yellow)
end

def first_js_statement_in_code(content)
def first_js_statement_in_code(content) # rubocop:disable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
return "" if content.nil? || content.empty?

start_index = 0
@@ -89,7 +89,8 @@ def client_entrypoint?(file_path)

def pack_file_contents(file_path)
registered_component_name = component_name(file_path)
load_server_components = ReactOnRails::Utils.react_on_rails_pro? && ReactOnRailsPro.configuration.enable_rsc_support
load_server_components = ReactOnRails::Utils.react_on_rails_pro? &&
ReactOnRailsPro.configuration.enable_rsc_support

if load_server_components && !client_entrypoint?(file_path)
rsc_rendering_url_path = ReactOnRailsPro.configuration.rsc_rendering_url_path
14 changes: 7 additions & 7 deletions spec/dummy/spec/packs_generator_spec.rb
Original file line number Diff line number Diff line change
@@ -82,7 +82,7 @@ module ReactOnRails
it "generated pack for ComponentWithCommonOnly uses common file for pack" do
pack_content = File.read(component_pack)

expect(pack_content).to include("#{component_namspec / dummy / spec / packs_generator_spec.rbe}.jsx")
expect(pack_content).to include("#{component_name}.jsx")
expect(pack_content).not_to include("#{component_name}.client.jsx")
expect(pack_content).not_to include("#{component_name}.server.jsx")
end
@@ -434,7 +434,7 @@ def stub_packer_source_path(packer_source_path:, component_name:)
end

context "with string directive" do
context "on top of the file" do
context "when on top of the file" do
let(:content) do
<<~JS
"use client";
@@ -446,13 +446,13 @@ def stub_packer_source_path(packer_source_path:, component_name:)
it { is_expected.to eq '"use client";' }
end

context "on top of the file and one line comment" do
context "when on top of the file and one line comment" do
let(:content) { '"use client"; // const x = 1' }

it { is_expected.to eq '"use client"; // const x = 1' }
end

context "after some one-line comments" do
context "when after some one-line comments" do
let(:content) do
<<~JS
// First comment
@@ -464,7 +464,7 @@ def stub_packer_source_path(packer_source_path:, component_name:)
it { is_expected.to eq '"use client";' }
end

context "after some multi-line comments" do
context "when after some multi-line comments" do
let(:content) do
<<~JS
/* First comment */
@@ -478,7 +478,7 @@ def stub_packer_source_path(packer_source_path:, component_name:)
it { is_expected.to eq '"use client";' }
end

context "after some mixed comments" do
context "when after some mixed comments" do
let(:content) do
<<~JS
// First comment
@@ -492,7 +492,7 @@ def stub_packer_source_path(packer_source_path:, component_name:)
it { is_expected.to eq '"use client";' }
end

context "after any non-comment code" do
context "when after any non-comment code" do
let(:content) do
<<~JS
// First comment