Skip to content

[mirror] Move Node Renderer entry point to renderer/ directory#6

Open
yashwant86 wants to merge 10 commits into
mm-base-3165from
mm-pr-3165
Open

[mirror] Move Node Renderer entry point to renderer/ directory#6
yashwant86 wants to merge 10 commits into
mm-base-3165from
mm-pr-3165

Conversation

@yashwant86
Copy link
Copy Markdown

@yashwant86 yashwant86 commented Apr 26, 2026

Mirror of upstream shakacode#3165 for benchmark. Do not merge.


Summary by MergeMonkey

  • Reference Updates:
    • Updated Node Renderer entry point references from client/ to renderer/ directory across all documentation and configuration files.
  • Spring Cleaning:
    • Migrated Node Renderer bootstrap file location from client/node-renderer.js to renderer/node-renderer.js.
    • Added legacy renderer detection and migration guidance for existing client/node-renderer.js setups.
    • Enhanced Procfile.dev management with regex-based detection of new and legacy renderer entries.

justin808 and others added 10 commits April 17, 2026 17:42
Establishes `renderer/node-renderer.js` as the canonical location for the
Pro Node Renderer entry point. Previously the path was inconsistent across
docs (`node-renderer.js`, `client/node-renderer.js`, or
`react-on-rails-pro-node-renderer.js`).

Using a dedicated top-level `renderer/` directory makes it trivial to
exclude from production Docker builds that strip JS sources after bundling
— the Node Renderer process still needs its entry file at runtime.

Changes:
- Generator (`pro_setup.rb`, `base_generator.rb`, `demo_page_config.rb`,
  USAGE, initializer template) now creates the entry at `renderer/node-renderer.js`
- Template file moved to `templates/pro/base/renderer/node-renderer.js`
- Pro `spec/dummy` renderer file, Procfile.dev, Procfile.prod,
  package.json scripts, .controlplane/rails.yml, and benchmark reference updated
- All 13 docs now use `renderer/node-renderer.js` consistently
- Container deployment doc explains the rationale for the dedicated directory
- Generator specs updated; 13 renderer-related specs pass

Existing apps are unaffected — the generator skips files that already
exist, so upgrades keep their current `client/node-renderer.js`.

Fixes shakacode#3073

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The previous link to main-branch GitHub URL fails link-check on the PR
branch because the file path has changed. Relative link works across all
branches and avoids the chicken-and-egg check on the renamed path.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…og polish

- pro_setup.rb: skip `create_node_renderer` when the legacy
  `client/node-renderer.js` exists, emitting a migration hint so existing
  Pro users don't silently end up with two renderer files after rerunning
  the generator. Added a spec covering the legacy-path case.
- docs/oss/.../js-configuration.md: revert the testing-example link to the
  absolute GitHub URL so hosted docs platforms don't 404 on a relative
  path that leaves the docs tree.
- CHANGELOG.md: split `**[Pro]**` from the entry title and add the PR
  attribution to match the project's changelog guidelines.
- packages/.../react-on-rails-pro-node-renderer/README.md: update the
  quickstart to reference `renderer/node-renderer.js` so the README
  matches the new generator default.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The absolute URL 404s on main until this PR merges, so the pre-push
lychee check rejects it. Keep the relative link which resolves correctly
on GitHub file browsing; hosted docs are served via GitHub, so the
reviewer's concern about Docusaurus-style resolution does not apply.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…irectory

Addresses PR shakacode#3165 review (claude[bot]):

- setup_pro now captures the return value of create_node_renderer.
  When a legacy client/node-renderer.js is present, create_node_renderer
  returns true, and setup_pro skips add_pro_to_procfile. Previously,
  legacy-renderer users could end up with a Procfile.dev entry pointing
  at renderer/node-renderer.js (a file deliberately not created),
  leaving the renderer process unable to start.
- create_node_renderer now uses Thor's empty_directory instead of
  FileUtils.mkdir_p, so it participates in --pretend / verbose output
  like the rest of the generator.
- Added a Procfile.dev assertion to the legacy-renderer spec to lock
  in the correct behavior.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The legacy-renderer branch of create_node_renderer returns early,
which also bypasses add_pro_to_procfile's "Procfile.dev not found"
warning that spells out the exact node-renderer: command. A user
with client/node-renderer.js and no Procfile.dev would get no
Procfile guidance at all. Echo the full command inline so it's
always visible.

Also adds a spec covering the case where renderer/node-renderer.js
exists but Procfile.dev lacks node-renderer: — create_node_renderer
returns false, add_pro_to_procfile runs, entry is appended.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- pro_setup.rb: broaden legacy-renderer migration hint to mention
  Procfile.prod and Docker CMD / command: alongside Procfile.dev so
  production configs aren't left pointing at the old client/ path.
- pro_setup.rb: correct create_node_renderer @return doc — method now
  always returns an explicit Boolean, never nil.
- renderer/node-renderer.js template: document that serverBundleCachePath
  resolves to <project-root>/.node-renderer-bundles.
- pro_generator_spec.rb: add coverage for mid-migration state where
  both renderer/node-renderer.js and client/node-renderer.js exist;
  asserts renderer/ guard fires first and Procfile.dev gets exactly
  one renderer/ entry.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Tighten `add_pro_to_procfile` guard so it only skips when Procfile.dev
  already references `renderer/node-renderer.js`. Stale legacy entries
  (e.g. `node client/node-renderer.js`) now surface an explicit warning
  instead of silently skipping, and are not duplicated with a new entry.
- Fix accidental `:):` punctuation in the legacy-renderer migration hint.
- Add specs: stale legacy Procfile entry path (warn + no duplicate) and
  idempotent no-op when Procfile.dev already has the new entry.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Match renderer command with regex so `node ./renderer/node-renderer.js`
  is recognized as already present (idempotency was too strict).
- When a legacy `client/node-renderer.js` is detected and Procfile.dev
  still launches it, surface a pointed warning pinpointing the stale
  line instead of leaving users to diff the generic migration hint.
- Add specs for both the `./`-prefixed command and the stale legacy
  Procfile entry.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

size-limit report 📦

Path Size
react-on-rails/client bundled (gzip) 62.76 KB (0%)
react-on-rails/client bundled (gzip) (time) 62.76 KB (0%)
react-on-rails/client bundled (brotli) 53.86 KB (0%)
react-on-rails/client bundled (brotli) (time) 53.86 KB (0%)
react-on-rails-pro/client bundled (gzip) 63.71 KB (0%)
react-on-rails-pro/client bundled (gzip) (time) 63.71 KB (0%)
react-on-rails-pro/client bundled (brotli) 54.63 KB (0%)
react-on-rails-pro/client bundled (brotli) (time) 54.63 KB (0%)
registerServerComponent/client bundled (gzip) 127.53 KB (0%)
registerServerComponent/client bundled (gzip) (time) 127.53 KB (0%)
registerServerComponent/client bundled (brotli) 61.7 KB (0%)
registerServerComponent/client bundled (brotli) (time) 61.7 KB (0%)
wrapServerComponentRenderer/client bundled (gzip) 122.02 KB (0%)
wrapServerComponentRenderer/client bundled (gzip) (time) 122.02 KB (0%)
wrapServerComponentRenderer/client bundled (brotli) 56.73 KB (0%)
wrapServerComponentRenderer/client bundled (brotli) (time) 56.73 KB (0%)

@bot-mergemonkey
Copy link
Copy Markdown

bot-mergemonkey Bot commented Apr 26, 2026

Risk AssessmentNEEDS-TESTING · ~25 min review

Focus areas: Legacy renderer detection and Procfile regex patterns · create_node_renderer return value flow control · Test coverage for edge cases (stale entries, ./ prefix, commented lines)

Assessment: Refactors generator logic for file placement and Procfile management with legacy migration support.

Walkthrough

When a user runs the Pro generator, it now creates the Node Renderer bootstrap file in renderer/node-renderer.js instead of client/node-renderer.js. If a legacy client/node-renderer.js already exists, the generator preserves it and displays migration guidance rather than creating a duplicate. The generator intelligently manages Procfile.dev entries using regex patterns to detect new, legacy, and stale renderer configurations, avoiding duplicate entries and warning users about outdated references.

Changes

Files Summary
Node Renderer File Relocation
react_on_rails/lib/generators/react_on_rails/templates/pro/base/renderer/node-renderer.js
Moved Node Renderer bootstrap template from client/ to renderer/ directory with updated path comment.
Generator Logic & Migration Support
react_on_rails/lib/generators/react_on_rails/pro_setup.rb
Refactored create_node_renderer to target renderer/ directory, added legacy client/node-renderer.js detection with user-friendly migration hints, implemented regex-based Procfile.dev entry detection to handle new/legacy/stale renderer paths, and conditionally skip Procfile updates when legacy renderer detected.
Test Suite Updates
react_on_rails/spec/react_on_rails/generators/install_generator_spec.rb
react_on_rails/spec/react_on_rails/generators/pro_generator_spec.rb
react_on_rails/spec/react_on_rails/support/shared_examples/pro_generator_examples.rb
Updated all test assertions to expect renderer/node-renderer.js path; added 10 new test contexts covering legacy detection, stale Procfile entries, ./ prefix handling, commented entries, and coexistence scenarios.
Generator Hints & Configuration
react_on_rails/lib/generators/react_on_rails/base_generator.rb
react_on_rails/lib/generators/react_on_rails/demo_page_config.rb
react_on_rails/lib/generators/react_on_rails/pro/USAGE
react_on_rails/lib/generators/react_on_rails/templates/pro/base/config/initializers/react_on_rails_pro.rb.tt
Updated generator hints, USAGE documentation, and initializer template to reference renderer/node-renderer.js path.
Dummy App Configuration
react_on_rails_pro/spec/dummy/Procfile.dev
react_on_rails_pro/spec/dummy/Procfile.prod
react_on_rails_pro/spec/dummy/package.json
benchmarks/bench-node-renderer.rb
Updated dummy app and benchmark configuration files to use renderer/node-renderer.js path in Procfile entries and npm scripts.
Documentation Updates
docs/oss/api-reference/generator-details.md
docs/oss/building-features/code-splitting.md
docs/oss/building-features/node-renderer/basics.md
docs/oss/building-features/node-renderer/container-deployment.md
docs/oss/building-features/node-renderer/debugging.md
docs/oss/building-features/node-renderer/heroku.md
docs/oss/building-features/node-renderer/js-configuration.md
docs/oss/deployment/docker-deployment.md
docs/oss/migrating/rsc-preparing-app.md
docs/oss/migrating/rsc-troubleshooting.md
docs/pro/installation.md
docs/pro/js-memory-leaks.md
docs/pro/profiling-server-side-rendering-code.md
packages/react-on-rails-pro-node-renderer/README.md
CHANGELOG.md
Updated all documentation and changelog to reflect renderer/node-renderer.js path in code examples, command references, and configuration snippets.

Sequence Diagram

sequenceDiagram
  participant User
  participant Generator
  participant FileSystem
  participant Procfile
  User->>Generator: Run Pro setup
  Generator->>FileSystem: Check renderer/node-renderer.js exists?
  alt New setup
    FileSystem-->>Generator: No
    Generator->>FileSystem: Check legacy client/node-renderer.js?
    alt Legacy exists
      FileSystem-->>Generator: Yes
      Generator->>User: Display migration hint
      Generator->>Procfile: Skip Procfile update
    else No legacy
      FileSystem-->>Generator: No
      Generator->>FileSystem: Create renderer/ directory
      Generator->>FileSystem: Copy template to renderer/node-renderer.js
      Generator->>Procfile: Add new node-renderer entry
      Generator->>User: Confirm creation
    end
  else Already exists
    FileSystem-->>Generator: Yes
    Generator->>User: Skip, already present
  end
  alt Procfile management
    Generator->>Procfile: Read Procfile.dev
    Generator->>Procfile: Check for NEW_RENDERER_COMMAND_REGEX
    alt Matches new pattern
      Procfile-->>Generator: Found
      Generator->>User: Skip, already configured
    else Check legacy pattern
      Procfile-->>Generator: Not found
      Generator->>Procfile: Check LEGACY_RENDERER_COMMAND_REGEX
      alt Matches legacy
        Procfile-->>Generator: Found
        Generator->>User: Warn about stale entry
      else No match
        Procfile-->>Generator: Not found
        Generator->>Procfile: Append new entry
      end
    end
  end
Loading

Dig Deeper With Commands

  • /review <file-path> <function-optional>
  • /chat <file-path> "<question>"
  • /roast <file-path>

Runs only when explicitly triggered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants