internal/planning/JS_PRO_PACKAGE_SEPARATION_PLAN.md
This comprehensive plan documents all architectural decisions and implementation steps for separating JavaScript Pro functionality from the core React-on-Rails package into a separate react-on-rails-pro package.
import ReactOnRails from 'react-on-rails'import ReactOnRails from 'react-on-rails-pro' (gets everything)^16.1.0)react-dom uses ^19.1.1 for react)"dependencies": { "react-on-rails": "^16.1.0" }globalThis.ReactOnRails.get() methodscreateReactOutput() and reactHydrateOrRender()Based on commit 4dee1ff3cff5998a38cfa758dec041ece9986623 analysis:
Core Package (MIT) - Pre-Force-Load Behavior:
register(), getComponent(), getStore(), etc.Pro Package - Post-Force-Load Behavior:
getOrWaitForComponent(), getOrWaitForStore(), reactOnRailsComponentLoaded(), etc.Checkpoint 1.1: Create directory structure
packages/react-on-rails-pro/ directorypackages/react-on-rails-pro/src/ directorypackages/react-on-rails-pro/tests/ directoryCheckpoint 1.2: Create package.json
packages/react-on-rails-pro/package.json with:
"name": "react-on-rails-pro""license": "UNLICENSED""dependencies": { "react-on-rails": "^16.1.0" }build, test, type-check)yarn install works in pro package directoryCheckpoint 1.3: Create TypeScript configuration
packages/react-on-rails-pro/tsconfig.jsonlib/Success Validation:
cd packages/react-on-rails-pro && yarn install succeedsCheckpoint 2.1: Create simple ComponentRegistry
packages/react-on-rails/src/ComponentRegistry.ts with:
registeredComponents = new Map())register(components) methodget(name) method with error on missing componentcomponents() method returning MapgetOrWaitForComponent() with message: 'getOrWaitForComponent requires react-on-rails-pro package'packages/react-on-rails/tests/ComponentRegistry.test.jsCheckpoint 2.2: Create simple StoreRegistry
packages/react-on-rails/src/StoreRegistry.ts with:
register(), getStore(), getStoreGenerator(), setStore(), clearHydratedStores(), storeGenerators(), stores()getOrWaitForStore(), getOrWaitForStoreGenerator()packages/react-on-rails/tests/StoreRegistry.test.jsCheckpoint 2.3: Create simple ClientRenderer
packages/react-on-rails/src/ClientRenderer.ts with:
clientStartup.ts implementationimport { get as getComponent } from './ComponentRegistry'renderComponent(domId: string) functionreactOnRailsComponentLoaded functionSuccess Validation:
Checkpoint 3.1: Update ReactOnRails.client.ts
import * as ComponentRegistry from './ComponentRegistry'import * as StoreRegistry from './StoreRegistry'Checkpoint 3.2: Update other core files
serverRenderReactComponent.ts to use globalThis.ReactOnRails.getComponent() instead of direct registry import./pro/ in core filesCheckpoint 3.3: Test core package independence
cd packages/react-on-rails && yarn testcd packages/react-on-rails && yarn buildSuccess Validation:
Checkpoint 4.1: Move Pro JavaScript/TypeScript files
packages/react-on-rails/src/pro/ to packages/react-on-rails-pro/src/ using git mvCallbackRegistry.tsClientSideRenderer.tsComponentRegistry.tsStoreRegistry.tsReactOnRailsRSC.tsregisterServerComponent/ directorywrapServerComponentRenderer/ directoryCheckpoint 4.2: Update import paths in moved files
react-on-rails package imports (56 imports updated)Checkpoint 4.3: Remove pro directory from core
packages/react-on-rails/src/pro/ directorySuccess Validation:
Checkpoint 5.1: Identify pro-related tests
streamServerRenderedReactComponent.test.jsxregisterServerComponent.client.test.jsxinjectRSCPayload.test.tsSuspenseHydration.test.tsxCheckpoint 5.2: Move pro tests
packages/react-on-rails-pro/tests/ using git mvCheckpoint 5.3: Update remaining core tests
Success Validation:
Checkpoint 6.1: Create pro package main entry point
packages/react-on-rails-pro/src/index.ts that:
import ReactOnRailsCore from 'react-on-rails'import * as ProComponentRegistry from './ComponentRegistry'import { renderOrHydrateComponent, hydrateStore } from './ClientSideRenderer'globalThis.ReactOnRails to pro versionCheckpoint 6.2: Configure pro package exports
packages/react-on-rails-pro/package.json exports section"." (main entry)"./RSCRoute""./RSCProvider""./registerServerComponent/client""./registerServerComponent/server""./wrapServerComponentRenderer/client""./wrapServerComponentRenderer/server""./ServerComponentFetchError"Checkpoint 6.3: Test pro package build and functionality
cd packages/react-on-rails-pro && yarn buildgetOrWaitForComponent, getOrWaitForStore)Success Validation:
Checkpoint 7.1: Update root workspace
package.json workspaces to include "packages/react-on-rails-pro""build" should build both packages"test" should run tests for both packages"type-check" should check both packagesCheckpoint 7.2: Test workspace functionality
yarn build builds both packages successfullyyarn test runs tests for both packagesyarn type-check checks both packagesSuccess Validation:
Checkpoint 8.1: Update LICENSE.md
Remove packages/react-on-rails/src/pro/ from Pro license section (no longer exists)
Add packages/react-on-rails-pro/ to Pro license section
Update license scope to accurately reflect new structure:
## MIT License applies to:
- `lib/react_on_rails/` (including specs)
- `packages/react-on-rails/` (including tests)
## React on Rails Pro License applies to:
- `packages/react-on-rails-pro/` (including tests) (NEW)
- `react_on_rails_pro/` (remaining files)
Verify all pro directories are listed correctly
Ensure no pro code remains in MIT-licensed directories
Checkpoint 8.2: Verify license compliance
packages/react-on-rails-pro/package.json has "license": "UNLICENSED"Success Validation:
Checkpoint 9.1: Core package testing
cd packages/react-on-rails && yarn testcd packages/react-on-rails && yarn buildCheckpoint 9.2: Pro package testing
cd packages/react-on-rails-pro && yarn testgetOrWaitForComponent)getOrWaitForStore)Checkpoint 9.3: Integration testing
yarn build from rootyarn test from rootSuccess Validation:
Checkpoint 10.1: Update package documentation
packages/react-on-rails-pro/README.md with installation and usage instructionsCheckpoint 10.2: Final cleanup and verification
yarn lint from rootyarn type-check from rootSuccess Validation:
# Test workspace
yarn build
yarn test
yarn type-check
yarn lint
# Test individual packages
cd packages/react-on-rails && yarn build && yarn test
cd packages/react-on-rails-pro && yarn build && yarn test
# Test in dummy app
cd react_on_rails/spec/dummy && yarn install && yarn build
"Step 4.1: Move pro files to pro package"git revert to undo problematic changesglobalThis.ReactOnRails for flexibilityThis implementation plan ensures a methodical approach to separating the pro functionality while maintaining all existing capabilities and providing clear upgrade paths for users.