Skip to content

Commit 158ac6c

Browse files
justin808claude
andcommitted
Extract React version check to separate script file
Address code review feedback: - Move inline version detection to scripts/check-react-version.cjs for better clarity and maintainability - Use .cjs extension since the parent package is ESM and we need require() - Add root Gemfile.lock to .gitignore (it's a delegate to react_on_rails/Gemfile) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent e85460d commit 158ac6c

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Root Gemfile.lock (delegates to react_on_rails/Gemfile, lock is there)
2+
/Gemfile.lock
3+
14
.bundle/
25
/.yardoc
36
/_yardoc/

packages/react-on-rails-pro/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"clean": "rm -rf ./lib",
1010
"test": "yarn test:non-rsc && yarn test:rsc",
1111
"test:non-rsc": "jest tests --testPathIgnorePatterns=\".*(RSC|stream|registerServerComponent|serverRenderReactComponent|SuspenseHydration).*\"",
12-
"test:rsc": "node -e \"const v = require('react/package.json').version; if (parseInt(v) < 19) { console.log('RSC tests skipped (requires React 19+, found ' + v + ')'); process.exit(0); } process.exit(1);\" || NODE_CONDITIONS=react-server jest tests/*.rsc.test.*",
12+
"test:rsc": "node scripts/check-react-version.cjs || NODE_CONDITIONS=react-server jest tests/*.rsc.test.*",
1313
"type-check": "yarn run tsc --noEmit --noErrorTruncation",
1414
"prepare": "[ -f lib/ReactOnRails.full.js ] || (rm -rf ./lib && tsc)",
1515
"prepublishOnly": "yarn run build",
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* Check if React version supports RSC features (React 19+).
3+
* Exits with code 0 if React < 19 (skip RSC tests).
4+
* Exits with code 1 if React >= 19 (run RSC tests).
5+
*
6+
* This is a CommonJS file (.cjs) because it needs to use require()
7+
* and the parent package has "type": "module".
8+
*/
9+
const v = require('react/package.json').version;
10+
11+
const majorVersion = parseInt(v, 10);
12+
13+
if (majorVersion < 19) {
14+
console.log(`RSC tests skipped (requires React 19+, found ${v})`);
15+
process.exit(0);
16+
}
17+
18+
// Exit with code 1 so the || chain continues to run Jest
19+
process.exit(1);

0 commit comments

Comments
 (0)