Skip to content

Commit 87087c8

Browse files
ihabadhamclaude
andcommitted
Fix cosmetic differences between standalone and fresh install output
- Add route reference to standalone Pro success message - Fix extractLoader blank line positioning with .chomp - Fix RSC plugin ordering to match template (before LimitChunkCountPlugin) - Fix RSC plugin indentation in serverWebpackConfig (2-space, not 4-space) - Fix clientWebpackConfig regex to not consume blank lines (\s* → ' *') - Add blank line between serverConfig and rscConfig in ServerClientOrBoth - Simplify React version warning to single npm command with ~19.0.3 - Remove stale @note comment about method call ordering These changes ensure standalone gsub transforms produce byte-identical webpack configs compared to the fresh install ERB template path. Co-Authored-By: Claude Opus 4.6 <[email protected]>
1 parent 9134e17 commit 87087c8

File tree

3 files changed

+13
-18
lines changed

3 files changed

+13
-18
lines changed

react_on_rails/lib/generators/react_on_rails/pro_generator.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ def print_success_message
8080
Next steps:
8181
1. Set your license: export REACT_ON_RAILS_PRO_LICENSE=your_token
8282
2. Start the app: bin/dev (or foreman start -f Procfile.dev)
83-
3. The Node Renderer will start on port 3800
83+
3. Visit http://localhost:3000/hello_world
84+
4. The Node Renderer will start on port 3800
8485
8586
Documentation: https://www.shakacode.com/react-on-rails-pro/docs/
8687
MSG

react_on_rails/lib/generators/react_on_rails/pro_setup.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,8 @@ def add_extract_loader_to_server_config(webpack_config, content)
222222
# Skip if extractLoader already exists
223223
return if content.include?("function extractLoader")
224224

225-
extract_loader_code = <<~JS
225+
extract_loader_code = <<~JS.chomp
226+
226227
227228
function extractLoader(rule, loaderName) {
228229
if (!Array.isArray(rule.use)) return null;

react_on_rails/lib/generators/react_on_rails/rsc_setup.rb

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ def setup_rsc
5656
# @param force [Boolean] When true, always performs the check.
5757
# When false (default), only checks if RSC is enabled (use_rsc? returns true).
5858
# Use force: true in standalone generators where RSC is always the purpose.
59-
# @note This should be called before setup_rsc to warn users early
6059
def warn_about_react_version_for_rsc(force: false)
6160
return unless force || use_rsc?
6261

@@ -72,12 +71,8 @@ def warn_about_react_version_for_rsc(force: false)
7271
React Server Components in React on Rails Pro currently only supports
7372
React 19.0.x. React 19.1.x and later are not yet supported.
7473
75-
To upgrade React:
76-
77-
78-
Or with your package manager:
79-
80-
74+
To install a compatible React version:
75+
npm install react@~19.0.3 react-dom@~19.0.3
8176
MSG
8277
elsif patch < 3
8378
GeneratorMessages.add_warning(<<~MSG.strip)
@@ -306,11 +301,11 @@ def update_server_client_or_both_for_rsc
306301
"\\1\nconst rscWebpackConfig = require('./rscWebpackConfig');"
307302
)
308303

309-
# Add rscConfig variable after serverConfig
304+
# Add rscConfig variable after serverConfig (with blank line separator)
310305
gsub_file(
311306
config_path,
312307
/^(\s*const serverConfig = serverWebpackConfig\(\);)$/,
313-
"\\1\n const rscConfig = rscWebpackConfig();"
308+
"\\1\n\n const rscConfig = rscWebpackConfig();"
314309
)
315310

316311
# Update envSpecific call to include rscConfig
@@ -372,17 +367,16 @@ def update_server_webpack_config_for_rsc
372367
"const configureServer = (rscBundle = false) => {"
373368
)
374369

375-
# Add RSCWebpackPlugin to plugins after LimitChunkCountPlugin
376-
rsc_plugin_code = "\n " \
377-
"// Add RSC plugin for server bundle (handles client component references)\n " \
370+
# Add RSCWebpackPlugin to plugins before LimitChunkCountPlugin (matches template ordering)
371+
rsc_plugin_code = "// Add RSC plugin for server bundle (handles client component references)\n " \
378372
"// Skip for RSC bundle - it doesn't need RSCWebpackPlugin\n " \
379373
"if (!rscBundle) {\n " \
380374
"serverWebpackConfig.plugins.push(new RSCWebpackPlugin({ isServer: true }));\n " \
381375
"}"
382376
gsub_file(
383377
config_path,
384378
/(serverWebpackConfig\.plugins\.unshift\(new bundler\.optimize\.LimitChunkCountPlugin.*\);)/,
385-
"\\1#{rsc_plugin_code}"
379+
"#{rsc_plugin_code}\n \\1"
386380
)
387381
end
388382

@@ -405,12 +399,11 @@ def update_client_webpack_config_for_rsc
405399
)
406400

407401
# Add RSCWebpackPlugin to client config before return statement
408-
rsc_plugin_code = "\n " \
409-
"// Add React Server Components plugin for client bundle\n " \
402+
rsc_plugin_code = " // Add React Server Components plugin for client bundle\n " \
410403
"clientConfig.plugins.push(new RSCWebpackPlugin({ isServer: false }));"
411404
gsub_file(
412405
config_path,
413-
/^(\s*return clientConfig;)$/,
406+
/^( *return clientConfig;)$/,
414407
"#{rsc_plugin_code}\n\n\\1"
415408
)
416409
end

0 commit comments

Comments
 (0)