Skip to content

Commit 325f3e3

Browse files
ihabadhamclaude
andcommitted
Add RSCWebpackPlugin to client webpack config
RSCWebpackPlugin({ isServer: false }) on the client bundle scans for 'use client' files and adds them as entry points so they appear in the client manifest (react-client-manifest.json). Without this, client components referenced in RSC payloads wouldn't have matching chunks in the client bundle. clientReferences scoped to config.source_path, consistent with the server bundle's scoping in serverWebpackConfig.js. Reference: Pro dummy clientWebpackConfig.js:16-24. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 2424b1c commit 325f3e3

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

config/webpack/clientWebpackConfig.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
// The source code including full typescript support is available at:
22
// https://github.com/shakacode/react_on_rails_tutorial_with_ssr_and_hmr_fast_refresh/blob/master/config/webpack/clientWebpackConfig.js
33

4+
const path = require('path');
5+
const { config } = require('shakapacker');
6+
const { RSCWebpackPlugin } = require('react-on-rails-rsc/WebpackPlugin');
47
const commonWebpackConfig = require('./commonWebpackConfig');
58
const { getBundler } = require('./bundlerUtils');
69

@@ -22,6 +25,16 @@ const configureClient = () => {
2225
// client config is going to try to load chunks.
2326
delete clientConfig.entry['server-bundle'];
2427

28+
const clientReferencesDir = path.resolve(config.source_path || 'client/app');
29+
clientConfig.plugins.push(
30+
new RSCWebpackPlugin({
31+
isServer: false,
32+
clientReferences: [
33+
{ directory: clientReferencesDir, recursive: true, include: /\.(js|ts|jsx|tsx)$/ },
34+
],
35+
}),
36+
);
37+
2538
return clientConfig;
2639
};
2740

0 commit comments

Comments
 (0)