Commit ca7dd22
Add React 19 webpack configuration and build support
This PR adds the necessary webpack configuration changes to support
React 19's new module system and build requirements.
## Changes
### Webpack Server Bundle Configuration
**Target Configuration:**
- Set `target: 'node'` to properly externalize Node.js built-in modules
- React 19's react-dom/server includes Node.js-specific code (crypto, async_hooks, stream)
- Without this, webpack tries to bundle these modules and fails
**Condition Names:**
- Set `resolve.conditionNames` to prevent react-server condition resolution
- React 19 has conditional exports with 'react-server' condition
- Server SSR bundles need full React with hooks, not the react-server build
- Explicitly set: `['node', 'import', 'require', 'default']`
**Library Target:**
- Removed `libraryTarget: 'commonjs2'` for ExecJS compatibility
- Only needed for Node renderer, breaks ExecJS (default)
- ExecJS doesn't provide Node's `require()` function
### Dependencies
Added SWC compiler dependencies (required by Shakapacker 9.3.0):
- `@swc/core` - SWC compiler core
- `swc-loader` - Webpack loader for SWC
Applied to:
- spec/dummy/package.json
- react_on_rails_pro/spec/dummy/package.json
- react_on_rails_pro/spec/execjs-compatible-dummy/package.json
### Generator Templates
Updated generator template with:
- Proper webpack configuration for React 19
- Clear comments about when to use libraryTarget: 'commonjs2'
- Target: node configuration
## Testing
✅ Local builds pass
✅ Server rendering works with ExecJS
✅ Node.js modules properly externalized
## Impact
This is a foundational change that enables React 19 support.
All other React 19 changes depend on this working correctly.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>1 parent 23be9a9 commit ca7dd22
File tree
6 files changed
+48
-6
lines changed- lib/generators/react_on_rails/templates/base/base/config/webpack
- react_on_rails_pro/spec
- dummy
- execjs-compatible-dummy
- config/webpack
- spec/dummy
- config/webpack
6 files changed
+48
-6
lines changedLines changed: 14 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
| 54 | + | |
53 | 55 | | |
54 | 56 | | |
55 | 57 | | |
| |||
111 | 113 | | |
112 | 114 | | |
113 | 115 | | |
114 | | - | |
115 | | - | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
116 | 128 | | |
117 | 129 | | |
118 | 130 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| 82 | + | |
82 | 83 | | |
83 | 84 | | |
84 | 85 | | |
| |||
88 | 89 | | |
89 | 90 | | |
90 | 91 | | |
| 92 | + | |
91 | 93 | | |
92 | 94 | | |
93 | 95 | | |
| |||
Lines changed: 14 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
| 52 | + | |
51 | 53 | | |
52 | 54 | | |
53 | 55 | | |
| |||
109 | 111 | | |
110 | 112 | | |
111 | 113 | | |
112 | | - | |
113 | | - | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
114 | 126 | | |
115 | 127 | | |
116 | 128 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
47 | 48 | | |
| 49 | + | |
48 | 50 | | |
49 | 51 | | |
50 | 52 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
| 49 | + | |
48 | 50 | | |
49 | 51 | | |
50 | 52 | | |
| |||
107 | 109 | | |
108 | 110 | | |
109 | 111 | | |
110 | | - | |
111 | | - | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
112 | 124 | | |
113 | 125 | | |
114 | 126 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
| |||
53 | 54 | | |
54 | 55 | | |
55 | 56 | | |
| 57 | + | |
56 | 58 | | |
57 | 59 | | |
58 | 60 | | |
| |||
0 commit comments