Skip to content

Commit 93a456f

Browse files
AbanoubGhadbanjustin808claude
authored
Make the dummy use private server bundle path and migrate to react on rails v16.1.1 (#558)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - New Features - Added SSR configurables: new server bundle output path and enforcement of private server bundles. - Chores - Raised minimum ReactOnRails compatibility to >= 16 and updated development dependency source/version. - Ignored SSR-generated artifacts; CI caching/cleanup and build/clean now handle SSR output. - Tests - Updated test setup and bundle paths to use the new SSR output location and adjusted a test expectation attribute. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Justin Gordon <[email protected]> Co-authored-by: Claude <[email protected]>
1 parent 086261d commit 93a456f

File tree

19 files changed

+74
-38
lines changed

19 files changed

+74
-38
lines changed

.circleci/config.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ jobs:
224224
key: v4-dummy-app-webpack-bundle-{{ .Revision }}
225225
paths:
226226
- spec/dummy/public/webpack/test
227+
- spec/dummy/ssr-generated
227228

228229
# Run JS unit tests for Renderer package.
229230
package-js-tests:
@@ -234,6 +235,7 @@ jobs:
234235
- run: *print-system-info
235236
- restore_cache: *restore-package-node-modules-cache
236237
- run: rm -rf spec/dummy/public/webpack
238+
- run: rm -rf spec/dummy/ssr-generated
237239
- restore_cache: *restore-dummy-app-webpack-bundle-cache
238240
- run: *install-package-node-modules
239241
# https://circleci.com/docs/collect-test-data/#jest
@@ -279,6 +281,7 @@ jobs:
279281
- restore_cache: *restore-dummy-app-node-modules-cache
280282
- restore_cache: *restore-dummy-app-gem-cache
281283
- run: rm -rf spec/dummy/public/webpack
284+
- run: rm -rf spec/dummy/ssr-generated
282285
- restore_cache: *restore-dummy-app-webpack-bundle-cache
283286
- run: *install-dummy-app-ruby-gems
284287
- run: *install-package-node-modules

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ yarn-debug.*
5454
spec/dummy/client/yarn-debug.log*
5555
npm-debug.*
5656
spec/dummy/client/npm-debug.log*
57+
spec/dummy/ssr-generated/
5758

5859
/gen-examples
5960

Gemfile.development_dependencies

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
55

66
ruby '3.3.7'
77

8-
gem "react_on_rails", "15.0.0" # keep in sync with package.json files
8+
gem "react_on_rails", "16.1.1"
99

1010
# For local development
1111
# Add the following line to the Gemfile.local file

Gemfile.lock

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ PATH
1515
execjs (~> 2.9)
1616
httpx (~> 1.5)
1717
rainbow
18-
react_on_rails (>= 15.0.0)
18+
react_on_rails (>= 16.0.0)
1919

2020
GEM
2121
remote: https://rubygems.org/
@@ -288,12 +288,13 @@ GEM
288288
ffi (~> 1.0)
289289
rdoc (6.12.0)
290290
psych (>= 4.0.0)
291-
react_on_rails (15.0.0)
291+
react_on_rails (16.1.1)
292292
addressable
293293
connection_pool
294294
execjs (~> 2.5)
295295
rails (>= 5.2)
296296
rainbow (~> 3.0)
297+
shakapacker (>= 6.0)
297298
regexp_parser (2.9.2)
298299
reline (0.6.0)
299300
io-console (~> 0.5)
@@ -468,7 +469,7 @@ DEPENDENCIES
468469
pry-theme
469470
puma (~> 6)
470471
rails (~> 7.1)
471-
react_on_rails (= 15.0.0)
472+
react_on_rails (= 16.1.1)
472473
react_on_rails_pro!
473474
rspec-rails
474475
rspec-retry

lib/react_on_rails_pro/utils.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,6 @@ def self.rsc_bundle_hash
6767

6868
# Returns the hashed file name when using webpacker. Useful for creating cache keys.
6969
def self.bundle_file_name(bundle_name)
70-
unless ReactOnRails::PackerUtils.using_packer?
71-
raise ReactOnRailsPro::Error, "Only call bundle_file_name if using webpacker"
72-
end
73-
7470
# bundle_js_uri_from_packer can return a file path or a HTTP URL (for files served from the dev server)
7571
# Pathname can handle both cases
7672
full_path = ReactOnRails::PackerUtils.bundle_js_uri_from_packer(bundle_name)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
"nps": "^5.9.12",
8686
"pino-pretty": "^13.0.0",
8787
"prettier": "^3.2.5",
88-
"react-on-rails": "15.0.0",
88+
"react-on-rails": "16.1.1",
8989
"redis": "^5.0.1",
9090
"release-it": "^17.6.0",
9191
"sentry-testkit": "^5.0.6",

packages/node-renderer/tests/htmlStreaming.test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ const createForm = ({ project = 'spec-dummy', commit = '', props = {}, throwJsEr
4343
}
4444
form.append('renderingRequest', renderingRequestCode);
4545

46-
const testBundlesDirectory = path.join(__dirname, '../../../spec/dummy/public/webpack/test');
46+
const testBundlesDirectory = path.join(__dirname, '../../../spec/dummy/ssr-generated');
47+
const testClientBundlesDirectory = path.join(__dirname, '../../../spec/dummy/public/webpack/test');
4748
const bundlePath = path.join(testBundlesDirectory, 'server-bundle.js');
4849
form.append(`bundle_${SERVER_BUNDLE_TIMESTAMP}`, fs.createReadStream(bundlePath), {
4950
contentType: 'text/javascript',
@@ -54,7 +55,7 @@ const createForm = ({ project = 'spec-dummy', commit = '', props = {}, throwJsEr
5455
contentType: 'text/javascript',
5556
filename: 'rsc-bundle.js',
5657
});
57-
const clientManifestPath = path.join(testBundlesDirectory, 'react-client-manifest.json');
58+
const clientManifestPath = path.join(testClientBundlesDirectory, 'react-client-manifest.json');
5859
form.append('asset1', fs.createReadStream(clientManifestPath), {
5960
contentType: 'application/json',
6061
filename: 'react-client-manifest.json',

packages/node-renderer/tests/serverRenderRSCReactComponent.test.js

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import path from 'path';
2+
import fs from 'fs';
23
import { Readable } from 'stream';
34
import { buildVM, getVMContext, resetVM } from '../src/worker/vm';
45
import { getConfig } from '../src/shared/configBuilder';
@@ -17,6 +18,36 @@ const ComponentWithAsyncError = async () => {
1718
};
1819

1920
describe('serverRenderRSCReactComponent', () => {
21+
let tempDir;
22+
let tempRscBundlePath;
23+
let tempManifestPath;
24+
25+
beforeAll(async () => {
26+
// Create temporary directory
27+
tempDir = path.join(process.cwd(), 'tmp/node-renderer-bundles-test/testing-bundle');
28+
fs.mkdirSync(tempDir, { recursive: true });
29+
30+
// Copy rsc-bundle.js to temp directory
31+
const originalRscBundlePath = path.join(__dirname, '../../../spec/dummy/ssr-generated/rsc-bundle.js');
32+
tempRscBundlePath = path.join(tempDir, 'rsc-bundle.js');
33+
fs.copyFileSync(originalRscBundlePath, tempRscBundlePath);
34+
35+
// Copy react-client-manifest.json to temp directory
36+
const originalManifestPath = path.join(
37+
__dirname,
38+
'../../../spec/dummy/public/webpack/test/react-client-manifest.json',
39+
);
40+
tempManifestPath = path.join(tempDir, 'react-client-manifest.json');
41+
fs.copyFileSync(originalManifestPath, tempManifestPath);
42+
});
43+
44+
afterAll(async () => {
45+
// Clean up temporary directory
46+
if (tempDir && fs.existsSync(tempDir)) {
47+
fs.rmSync(tempDir, { recursive: true, force: true });
48+
}
49+
});
50+
2051
beforeEach(async () => {
2152
const config = getConfig();
2253
config.supportModules = true;
@@ -31,10 +62,9 @@ describe('serverRenderRSCReactComponent', () => {
3162
// The serverRenderRSCReactComponent function should only be called when the bundle is compiled with the `react-server` condition.
3263
// Therefore, we cannot call it directly in the test files. Instead, we run the RSC bundle through the VM and call the method from there.
3364
const getReactOnRailsRSCObject = async () => {
34-
const testBundlesDirectory = path.join(__dirname, '../../../spec/dummy/public/webpack/test');
35-
const rscBundlePath = path.join(testBundlesDirectory, 'rsc-bundle.js');
36-
await buildVM(rscBundlePath);
37-
const vmContext = getVMContext(rscBundlePath);
65+
// Use the copied rsc-bundle.js file from temp directory
66+
await buildVM(tempRscBundlePath);
67+
const vmContext = getVMContext(tempRscBundlePath);
3868
const { ReactOnRails, React } = vmContext.context;
3969

4070
function SuspensedComponentWithAsyncError() {
@@ -68,7 +98,7 @@ describe('serverRenderRSCReactComponent', () => {
6898
throwJsErrors,
6999
railsContext: {
70100
serverSide: true,
71-
reactClientManifestFileName: 'react-client-manifest.json',
101+
reactClientManifestFileName: path.basename(tempManifestPath),
72102
reactServerClientManifestFileName: 'react-server-client-manifest.json',
73103
renderingReturnsPromises: true,
74104
},

react_on_rails_pro.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Gem::Specification.new do |s|
3333
s.add_runtime_dependency "execjs", "~> 2.9"
3434
s.add_runtime_dependency "httpx", "~> 1.5"
3535
s.add_runtime_dependency "rainbow"
36-
s.add_runtime_dependency "react_on_rails", ">= 15.0.0"
36+
s.add_runtime_dependency "react_on_rails", ">= 16.0.0"
3737
s.add_development_dependency "bundler"
3838
s.add_development_dependency "commonmarker"
3939
s.add_development_dependency "gem-release"

spec/dummy/.rubocop.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ AllCops:
1111
- 'node_modules/react-on-rails'
1212
- 'node_modules/**/*'
1313
- 'public/webpack/**/*'
14+
- 'ssr-generated/**/*'
1415

1516
Metrics/BlockLength:
1617
Exclude:

0 commit comments

Comments
 (0)