Skip to content

Commit 16f2f23

Browse files
committed
Fix Pro RSC Rspack gate review blockers
1 parent 0f2bffa commit 16f2f23

5 files changed

Lines changed: 24 additions & 9 deletions

File tree

.github/workflows/pro-integration-tests.yml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -554,8 +554,11 @@ jobs:
554554
needs.detect-changes.outputs.run_pro_dummy_tests == 'true'
555555
)
556556
runs-on: ubuntu-22.04
557+
timeout-minutes: 30
557558
env:
558559
REACT_ON_RAILS_PRO_LICENSE: ${{ secrets.REACT_ON_RAILS_PRO_LICENSE_V2 }}
560+
REACT_RENDERER_URL: http://127.0.0.1:3800
561+
RENDERER_HOST: 127.0.0.1
559562
SHAKAPACKER_ASSETS_BUNDLER: rspack
560563
services:
561564
redis:
@@ -689,13 +692,14 @@ jobs:
689692
690693
wait_for_h2c_service() {
691694
name="$1"
692-
authority="$2"
693-
path="$3"
695+
path="$2"
696+
shift 2
694697
timeout=300
695698
elapsed=0
696699
697700
while true; do
698-
if node - "$authority" "$path" <<'NODE'
701+
for authority in "$@"; do
702+
if node - "$authority" "$path" <<'NODE'
699703
const http2 = require('node:http2');
700704
701705
const [authority, path] = process.argv.slice(2);
@@ -721,10 +725,11 @@ jobs:
721725
request.end();
722726
setTimeout(fail, 2000);
723727
NODE
724-
then
725-
echo "${name} started at ${authority}${path} after ${elapsed}s"
726-
return 0
727-
fi
728+
then
729+
echo "${name} started at ${authority}${path} after ${elapsed}s"
730+
return 0
731+
fi
732+
done
728733
729734
sleep 1
730735
elapsed=$((elapsed + 1))
@@ -736,7 +741,7 @@ jobs:
736741
}
737742
738743
wait_for_service "Rails server" true "http://localhost:3000/empty"
739-
wait_for_h2c_service "Node renderer" "http://[::1]:3800" "/info"
744+
wait_for_h2c_service "Node renderer" "/info" "http://127.0.0.1:3800" "http://[::1]:3800"
740745
741746
- name: Install Playwright dependencies
742747
run: cd spec/dummy && npx playwright install --with-deps

react_on_rails_pro/spec/dummy/config/rspack/rspack.config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Set this before loading the shared webpack config because Shakapacker reads
22
// the assets_bundler setting while its config module is required.
3+
// Rspack CLI invokes this file in a fresh Node process, so webpack.config has
4+
// not already been cached with the default webpack bundler.
35
const previousAssetsBundler = process.env.SHAKAPACKER_ASSETS_BUNDLER;
46
process.env.SHAKAPACKER_ASSETS_BUNDLER = 'rspack';
57

react_on_rails_pro/spec/dummy/config/webpack/rscWebpackConfig.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ const configureRsc = () => {
103103
if (typeof rule.use === 'function') {
104104
// Skip if already wrapped by a previous configureRsc() call.
105105
// originalUse is captured before injection, so it cannot return the RSC loader itself.
106+
// rule.use.name is stable in Node.js build processes because these configs are not minified.
106107
if (rule.use.name === 'rscLoaderWrapper') return;
107108
const originalUse = rule.use;
108109
// eslint-disable-next-line no-param-reassign

react_on_rails_pro/spec/dummy/config/webpack/serverWebpackConfig.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
/* eslint-disable no-param-reassign */
22
const { config } = require('shakapacker');
3+
// The bundler choice is read at module load; tests that switch bundlers must
4+
// set SHAKAPACKER_ASSETS_BUNDLER before requiring this file or reset the cache.
35
const bundler = config.assets_bundler === 'rspack' ? require('@rspack/core') : require('webpack');
46
const RSCManifestPlugin =
57
config.assets_bundler === 'rspack'

react_on_rails_pro/spec/dummy/tests/rsc-rspack-config.test.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,12 @@ describe('Pro dummy RSC rspack config', () => {
7575
};
7676
const configureServer = jest.fn(() => serverConfig);
7777
const extractLoader = (rule, loaderName) =>
78-
Array.isArray(rule.use) ? rule.use.find((item) => item?.loader?.includes(loaderName)) : null;
78+
Array.isArray(rule.use)
79+
? rule.use.find((item) => {
80+
const testValue = typeof item === 'string' ? item : (item?.loader ?? '');
81+
return testValue.includes(loaderName);
82+
})
83+
: null;
7984

8085
jest.doMock(serverConfigPath, () => ({
8186
default: configureServer,

0 commit comments

Comments
 (0)