Skip to content

Commit a2ecdd2

Browse files
alexeyr-cialexeyr
andauthored
Update React to v19 (#1677)
* Update React in root to v19 * Upgrade React to v19 in spec/dummy * Upgrade ReScript * Replace .bs.js with preferred .res.js --------- Co-authored-by: Alexey Romanov <[email protected]>
1 parent 8a308b5 commit a2ecdd2

File tree

13 files changed

+99
-88
lines changed

13 files changed

+99
-88
lines changed

.prettierignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ spec/dummy/lib/bs/**
1111
spec/dummy/public
1212
**/.yalc/**
1313
**/generated/**
14-
*.bs.js
14+
*.res.js

node_package/tests/jest.setup.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,31 @@ if (typeof window !== 'undefined' && typeof window.TextEncoder !== 'undefined')
55
throw new Error('TextEncoder is already defined, remove the polyfill');
66
}
77

8+
// Similarly for MessageChannel
9+
if (typeof window !== 'undefined' && typeof window.MessageChannel !== 'undefined') {
10+
throw new Error('MessageChannel is already defined, remove the polyfill');
11+
}
12+
813
if (typeof window !== 'undefined') {
914
// eslint-disable-next-line global-require
1015
const { TextEncoder, TextDecoder } = require('util');
1116
global.TextEncoder = TextEncoder;
1217
global.TextDecoder = TextDecoder;
18+
19+
// https://github.com/jsdom/jsdom/issues/2448#issuecomment-1703763542
20+
global.MessageChannel = jest.fn().mockImplementation(() => {
21+
let onmessage;
22+
return {
23+
port1: {
24+
set onmessage(cb) {
25+
onmessage = cb;
26+
},
27+
},
28+
port2: {
29+
postMessage: (data) => {
30+
onmessage?.({ data });
31+
},
32+
},
33+
};
34+
});
1335
}

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
"@babel/preset-react": "^7.18.6",
2121
"@babel/types": "^7.20.7",
2222
"@types/jest": "^29.5.14",
23-
"@types/react": "^18.2.0",
24-
"@types/react-dom": "^18.2.0",
23+
"@types/react": "^18.3.18",
24+
"@types/react-dom": "^18.3.5",
2525
"@types/turbolinks": "^5.2.2",
2626
"@types/webpack-env": "^1.18.4",
2727
"@typescript-eslint/eslint-plugin": "^6.18.1",
@@ -42,8 +42,8 @@
4242
"prettier": "^2.8.8",
4343
"prettier-eslint-cli": "^5.0.0",
4444
"prop-types": "^15.8.1",
45-
"react": "18.3.0-canary-670811593-20240322",
46-
"react-dom": "18.3.0-canary-670811593-20240322",
45+
"react": "^19.0.0",
46+
"react-dom": "^19.0.0",
4747
"react-transform-hmr": "^1.0.4",
4848
"redux": "^4.2.1",
4949
"ts-jest": "^29.2.5",

spec/dummy/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ yarn-debug.log*
3434
/.merlin
3535
/lib/bs/
3636
/.bsb.lock
37-
*.bs.js
37+
*.res.js
3838

3939
# File Generated by ROR FS-based Registry
4040
**/generated

spec/dummy/.prettierignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
node_modules
22
public/webpack/
3-
*.bs.js
3+
*.res.js
44
lib/bs/**
55

66
# File Generated by ROR FS-based Registry

spec/dummy/babel.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ module.exports = function (api) {
1010
'@babel/preset-react',
1111
{
1212
development: !isProductionEnv,
13+
runtime: 'automatic',
1314
useBuiltIns: true,
1415
},
1516
],
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// This file is used to import your compiled rescript files
2-
// As per the current configuration, all files are compiled to .bs.js
2+
// As per the current configuration, all files are compiled to .res.js
33
// and they are generated on the same directory as the .res file
44

5-
import HelloWorldReScript from '../components/HelloWorldReScript.bs.js';
5+
import HelloWorldReScript from '../components/HelloWorldReScript.res.js';
66

77
export { HelloWorldReScript };
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
import HelloWorldReScript from '../components/HelloWorldReScript.bs.js';
1+
import HelloWorldReScript from '../components/HelloWorldReScript.res.js';
22

33
export default HelloWorldReScript;

spec/dummy/package.json

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"@babel/preset-react": "^7.10.4",
1414
"@babel/runtime": "7.17.9",
1515
"@hotwired/turbo-rails": "^8.0.4",
16-
"@rescript/react": "^0.10.3",
16+
"@rescript/react": "^0.13.0",
1717
"babel-loader": "8.2.4",
1818
"babel-plugin-macros": "^3.1.0",
1919
"babel-plugin-module-resolver": "^4.0.0",
@@ -37,16 +37,15 @@
3737
"nps": "^5.10.0",
3838
"null-loader": "^4.0.0",
3939
"prop-types": "^15.7.2",
40-
"react": "^18.2.0",
41-
"react-dom": "^18.2.0",
40+
"react": "^19.0.0",
41+
"react-dom": "^19.0.0",
4242
"react-helmet": "^6.1.0",
4343
"react-on-rails": "link:.yalc/react-on-rails",
44-
"react-proptypes": "^1.0.0",
4544
"react-redux": "^8.0.2",
4645
"react-router-dom": "^5.2.0",
4746
"redux": "^4.0.1",
4847
"redux-thunk": "^2.2.0",
49-
"rescript": "^9.1.4",
48+
"rescript": "^11.1.4",
5049
"resolve-url-loader": "^3.1.1",
5150
"sass": "^1.43.4",
5251
"sass-loader": "^12.3.0",
@@ -62,8 +61,8 @@
6261
},
6362
"devDependencies": {
6463
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.1",
65-
"@types/react": "^18.0.14",
66-
"@types/react-dom": "^18.0.5",
64+
"@types/react": "^19.0.0",
65+
"@types/react-dom": "^19.0.0",
6766
"@types/react-helmet": "^6.1.5",
6867
"react-refresh": "^0.11.0",
6968
"webpack-dev-server": "^4.9.0"

spec/dummy/bsconfig.json renamed to spec/dummy/rescript.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,11 @@
66
"subdirs": true
77
}
88
],
9-
"reason": {
10-
"react-jsx": 3
11-
},
12-
"suffix": ".bs.js",
9+
"jsx": { "version": 4 },
10+
"suffix": ".res.js",
1311
"package-specs": [
1412
{
15-
"module": "es6",
13+
"module": "esmodule",
1614
"in-source": true
1715
}
1816
],

0 commit comments

Comments
 (0)