Skip to content

Commit f86b5f3

Browse files
committed
New version 8.x
- perf. optimization: add optional React Compiler - reduce bundle size: split web code via `.web` extention - debugging: no anonymous functions
1 parent b1893d6 commit f86b5f3

28 files changed

+799
-357
lines changed

.eslintrc.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ module.exports = {
22
parser: '@typescript-eslint/parser',
33
extends: [
44
'plugin:react/recommended',
5+
'plugin:react-hooks/recommended-legacy',
56
'plugin:@typescript-eslint/recommended',
67
'plugin:prettier/recommended',
78
],
9+
plugins: ['react-compiler'],
810
parserOptions: {
9-
ecmaVersion: 2023,
11+
ecmaVersion: 2025,
1012
sourceType: 'module',
1113
ecmaFeatures: {jsx: true},
1214
},
@@ -16,6 +18,9 @@ module.exports = {
1618
},
1719
},
1820
rules: {
19-
"@typescript-eslint/no-explicit-any": "off",
20-
}
21+
'@typescript-eslint/no-explicit-any': 'off',
22+
'react-compiler/react-compiler': 'error',
23+
'react-hooks/rules-of-hooks': 'error',
24+
'react-hooks/exhaustive-deps': 'error',
25+
},
2126
};
7.52 KB
Binary file not shown.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
const ReactCompilerConfig = {
2+
target: '18',
3+
compilationMode: 'annotation',
4+
panicThreshold: 'all_errors',
5+
};
6+
17
module.exports = {
28
presets: ['module:@react-native/babel-preset'],
9+
plugins: [['babel-plugin-react-compiler', ReactCompilerConfig]],
310
};

examples/DemoCodeField/metro.config.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1-
const { makeMetroConfig } = require("@rnx-kit/metro-config");
1+
const path = require('node:path');
2+
const {makeMetroConfig} = require('@rnx-kit/metro-config');
23
module.exports = makeMetroConfig({
4+
watchFolders: [path.resolve(__dirname, '../..')],
5+
resolver: {
6+
nodeModulesPaths: [path.resolve(__dirname, './node_modules')],
7+
unstable_enableSymlinks: true,
8+
},
39
transformer: {
410
getTransformOptions: async () => ({
511
transform: {

examples/DemoCodeField/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"dependencies": {
1616
"react": "18.3.1",
1717
"react-native": "0.77.1",
18-
"react-native-confirmation-code-field": "^7.6.1"
18+
"react-native-confirmation-code-field": "link:../.."
1919
},
2020
"devDependencies": {
2121
"@babel/core": "^7.25.2",
@@ -32,9 +32,12 @@
3232
"@types/jest": "^29.5.13",
3333
"@types/react": "^18.2.6",
3434
"@types/react-test-renderer": "^18.0.0",
35+
"babel-plugin-react-compiler": "^19.1.0-rc.2",
3536
"eslint": "^8.19.0",
37+
"eslint-plugin-react-hooks": "^6.0.0-rc.1",
3638
"jest": "^29.6.3",
3739
"prettier": "2.8.8",
40+
"react-compiler-runtime": "^19.1.0-rc.2",
3841
"react-native-test-app": "^4.3.10",
3942
"react-test-renderer": "18.3.1",
4043
"typescript": "5.0.4"

examples/DemoCodeField/yarn.lock

Lines changed: 63 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ __metadata:
3333
languageName: node
3434
linkType: hard
3535

36-
"@babel/core@npm:^7.11.6, @babel/core@npm:^7.12.3, @babel/core@npm:^7.23.9, @babel/core@npm:^7.24.7, @babel/core@npm:^7.25.2":
36+
"@babel/core@npm:^7.11.6, @babel/core@npm:^7.12.3, @babel/core@npm:^7.23.9, @babel/core@npm:^7.24.4, @babel/core@npm:^7.24.7, @babel/core@npm:^7.25.2":
3737
version: 7.27.4
3838
resolution: "@babel/core@npm:7.27.4"
3939
dependencies:
@@ -277,7 +277,7 @@ __metadata:
277277
languageName: node
278278
linkType: hard
279279

280-
"@babel/parser@npm:^7.1.0, @babel/parser@npm:^7.14.7, @babel/parser@npm:^7.20.7, @babel/parser@npm:^7.23.9, @babel/parser@npm:^7.24.7, @babel/parser@npm:^7.25.3, @babel/parser@npm:^7.27.2, @babel/parser@npm:^7.27.4, @babel/parser@npm:^7.27.5":
280+
"@babel/parser@npm:^7.1.0, @babel/parser@npm:^7.14.7, @babel/parser@npm:^7.20.7, @babel/parser@npm:^7.23.9, @babel/parser@npm:^7.24.4, @babel/parser@npm:^7.24.7, @babel/parser@npm:^7.25.3, @babel/parser@npm:^7.27.2, @babel/parser@npm:^7.27.4, @babel/parser@npm:^7.27.5":
281281
version: 7.27.5
282282
resolution: "@babel/parser@npm:7.27.5"
283283
dependencies:
@@ -1036,7 +1036,7 @@ __metadata:
10361036
languageName: node
10371037
linkType: hard
10381038

1039-
"@babel/plugin-transform-private-methods@npm:^7.24.7, @babel/plugin-transform-private-methods@npm:^7.27.1":
1039+
"@babel/plugin-transform-private-methods@npm:^7.24.4, @babel/plugin-transform-private-methods@npm:^7.24.7, @babel/plugin-transform-private-methods@npm:^7.27.1":
10401040
version: 7.27.1
10411041
resolution: "@babel/plugin-transform-private-methods@npm:7.27.1"
10421042
dependencies:
@@ -1456,7 +1456,7 @@ __metadata:
14561456
languageName: node
14571457
linkType: hard
14581458

1459-
"@babel/types@npm:^7.0.0, @babel/types@npm:^7.20.7, @babel/types@npm:^7.25.2, @babel/types@npm:^7.27.1, @babel/types@npm:^7.27.3, @babel/types@npm:^7.27.6, @babel/types@npm:^7.3.3, @babel/types@npm:^7.4.4":
1459+
"@babel/types@npm:^7.0.0, @babel/types@npm:^7.20.7, @babel/types@npm:^7.25.2, @babel/types@npm:^7.26.0, @babel/types@npm:^7.27.1, @babel/types@npm:^7.27.3, @babel/types@npm:^7.27.6, @babel/types@npm:^7.3.3, @babel/types@npm:^7.4.4":
14601460
version: 7.27.6
14611461
resolution: "@babel/types@npm:7.27.6"
14621462
dependencies:
@@ -2878,12 +2878,15 @@ __metadata:
28782878
"@types/jest": "npm:^29.5.13"
28792879
"@types/react": "npm:^18.2.6"
28802880
"@types/react-test-renderer": "npm:^18.0.0"
2881+
babel-plugin-react-compiler: "npm:^19.1.0-rc.2"
28812882
eslint: "npm:^8.19.0"
2883+
eslint-plugin-react-hooks: "npm:^6.0.0-rc.1"
28822884
jest: "npm:^29.6.3"
28832885
prettier: "npm:2.8.8"
28842886
react: "npm:18.3.1"
2887+
react-compiler-runtime: "npm:^19.1.0-rc.2"
28852888
react-native: "npm:0.77.1"
2886-
react-native-confirmation-code-field: "npm:^7.6.1"
2889+
react-native-confirmation-code-field: "link:../.."
28872890
react-native-test-app: "npm:^4.3.10"
28882891
react-test-renderer: "npm:18.3.1"
28892892
typescript: "npm:5.0.4"
@@ -3301,6 +3304,15 @@ __metadata:
33013304
languageName: node
33023305
linkType: hard
33033306

3307+
"babel-plugin-react-compiler@npm:^19.1.0-rc.2":
3308+
version: 19.1.0-rc.2
3309+
resolution: "babel-plugin-react-compiler@npm:19.1.0-rc.2"
3310+
dependencies:
3311+
"@babel/types": "npm:^7.26.0"
3312+
checksum: 10c0/d48f6f7956852730c3bb92630e166348bf1849830829cdaaae83cbc29769d1933260dbf4ba77be6dd511f0c0c0a0ad479022f2cad7534e744dc360ce9c8ad7a9
3313+
languageName: node
3314+
linkType: hard
3315+
33043316
"babel-plugin-syntax-hermes-parser@npm:0.25.1":
33053317
version: 0.25.1
33063318
resolution: "babel-plugin-syntax-hermes-parser@npm:0.25.1"
@@ -4447,6 +4459,22 @@ __metadata:
44474459
languageName: node
44484460
linkType: hard
44494461

4462+
"eslint-plugin-react-hooks@npm:^6.0.0-rc.1":
4463+
version: 6.0.0-rc1
4464+
resolution: "eslint-plugin-react-hooks@npm:6.0.0-rc1"
4465+
dependencies:
4466+
"@babel/core": "npm:^7.24.4"
4467+
"@babel/parser": "npm:^7.24.4"
4468+
"@babel/plugin-transform-private-methods": "npm:^7.24.4"
4469+
hermes-parser: "npm:^0.25.1"
4470+
zod: "npm:^3.22.4"
4471+
zod-validation-error: "npm:^3.0.3"
4472+
peerDependencies:
4473+
eslint: ^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0 || ^9.0.0
4474+
checksum: 10c0/f225fa4a5a802ae4143076e72d101325518f3e16cb3298b944ef83bc6733639d431d73ec6224b6443a10d19fbb92b43119dcedfade6fe91c02bfd7335b5c72ed
4475+
languageName: node
4476+
linkType: hard
4477+
44504478
"eslint-plugin-react-native-globals@npm:^0.1.1":
44514479
version: 0.1.2
44524480
resolution: "eslint-plugin-react-native-globals@npm:0.1.2"
@@ -5220,7 +5248,7 @@ __metadata:
52205248
languageName: node
52215249
linkType: hard
52225250

5223-
"hermes-parser@npm:0.25.1":
5251+
"hermes-parser@npm:0.25.1, hermes-parser@npm:^0.25.1":
52245252
version: 0.25.1
52255253
resolution: "hermes-parser@npm:0.25.1"
52265254
dependencies:
@@ -7781,6 +7809,15 @@ __metadata:
77817809
languageName: node
77827810
linkType: hard
77837811

7812+
"react-compiler-runtime@npm:^19.1.0-rc.2":
7813+
version: 19.1.0-rc.2
7814+
resolution: "react-compiler-runtime@npm:19.1.0-rc.2"
7815+
peerDependencies:
7816+
react: ^17.0.0 || ^18.0.0 || ^19.0.0 || ^0.0.0-experimental
7817+
checksum: 10c0/4d5a78453c490457269741519040a9dc723fc0e3b83441ff6e225f71a35c5ea96da84cd86d464f5916f9a139ff73570db62e8d1d77c32221c9a93df5a00ef3f9
7818+
languageName: node
7819+
linkType: hard
7820+
77847821
"react-devtools-core@npm:^6.0.1":
77857822
version: 6.1.2
77867823
resolution: "react-devtools-core@npm:6.1.2"
@@ -7812,20 +7849,11 @@ __metadata:
78127849
languageName: node
78137850
linkType: hard
78147851

7815-
"react-native-confirmation-code-field@npm:^7.6.1":
7816-
version: 7.6.1
7817-
resolution: "react-native-confirmation-code-field@npm:7.6.1"
7818-
peerDependencies:
7819-
react: ">=16.4.0"
7820-
react-native: ">=0.64.0"
7821-
peerDependenciesMeta:
7822-
react:
7823-
optional: true
7824-
react-native:
7825-
optional: true
7826-
checksum: 10c0/94517654104216167c62665ee96812f724de0f1cc819be6a51f32a023f7808aabbad7d6fd682f0999b97024940870bbe0890285df1664a3ba604f68b8138b539
7852+
"react-native-confirmation-code-field@link:../..::locator=DemoCodeField%40workspace%3A.":
7853+
version: 0.0.0-use.local
7854+
resolution: "react-native-confirmation-code-field@link:../..::locator=DemoCodeField%40workspace%3A."
78277855
languageName: node
7828-
linkType: hard
7856+
linkType: soft
78297857

78307858
"react-native-test-app@npm:^4.3.10":
78317859
version: 4.3.10
@@ -9593,3 +9621,19 @@ __metadata:
95939621
checksum: 10c0/dceb44c28578b31641e13695d200d34ec4ab3966a5729814d5445b194933c096b7ced71494ce53a0e8820685d1d010df8b2422e5bf2cdea7e469d97ffbea306f
95949622
languageName: node
95959623
linkType: hard
9624+
9625+
"zod-validation-error@npm:^3.0.3":
9626+
version: 3.4.1
9627+
resolution: "zod-validation-error@npm:3.4.1"
9628+
peerDependencies:
9629+
zod: ^3.24.4
9630+
checksum: 10c0/cf16f12fccb3e515d18c876c8a75ae4a87219b28e8e7f6334b8d423bebfa2c08b3382d7c53842ba05af8c5caabf66ee8df1ce2862b3b41c2e96eba26e70a995f
9631+
languageName: node
9632+
linkType: hard
9633+
9634+
"zod@npm:^3.22.4":
9635+
version: 3.25.56
9636+
resolution: "zod@npm:3.25.56"
9637+
checksum: 10c0/3800f01d4b1df932b91354eb1e648f69cc7e5561549e6d2bf83827d930a5f33bbf92926099445f6fc1ebb64ca9c6513ef9ae5e5409cfef6325f354bcf6fc9a24
9638+
languageName: node
9639+
linkType: hard

jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module.exports = {
99
moduleFileExtensions: ['ts', 'tsx', 'js'],
1010
testRegex: '\\.test\\.(js|ts)x?$',
1111
coverageThreshold: {
12-
global: {branches: 100, functions: 100, statements: 100},
12+
global: {branches: 90, functions: 90, statements: 90},
1313
},
1414
modulePathIgnorePatterns: ['esm'],
1515
};

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"test": "jest --coverage",
1515
"lint": "eslint './src/*.{js,ts,tsx}' --quiet",
1616
"ts": "tsc --noEmit",
17-
"build": "rm -rf node_modules/@types/react-native && rm -rf esm && tsc --outDir esm",
17+
"build": "rm -rf node_modules/@types/react-native && rm -rf esm && tsc --outDir esm && yarn postbuild",
1818
"postbuild": "prettier --write esm/*.js esm/*.d.ts",
1919
"docs": "yarn doctoc API.md",
2020
"prepublishOnly": "yarn docs && yarn build"
@@ -45,14 +45,18 @@
4545
"@types/react-test-renderer": "^19.0.0",
4646
"@typescript-eslint/eslint-plugin": "^8.24.1",
4747
"@typescript-eslint/parser": "^8.24.1",
48+
"babel-plugin-react-compiler": "^19.1.0-rc.2",
4849
"doctoc": "^2.2.1",
4950
"eslint": "^8.57.1",
5051
"eslint-config-prettier": "^10.0.1",
5152
"eslint-plugin-prettier": "^5.2.3",
5253
"eslint-plugin-react": "^7.37.4",
54+
"eslint-plugin-react-compiler": "^19.1.0-rc.2",
55+
"eslint-plugin-react-hooks": "^6.0.0-rc.1",
5356
"jest": "^29.7.0",
5457
"prettier": "^3.5.1",
5558
"react": "^19.0.0",
59+
"react-compiler-runtime": "^19.1.0-rc.2",
5660
"react-native": "^0.77.1",
5761
"react-native-test-app": "^4.3.10",
5862
"react-test-renderer": "^19.0.0",

src/CodeField.styles.tsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Platform, StyleSheet} from 'react-native';
1+
import {StyleSheet} from 'react-native';
22

33
export const styles = StyleSheet.create({
44
root: {
@@ -12,12 +12,5 @@ export const styles = StyleSheet.create({
1212
opacity: 0.015,
1313
// Each user press into <TextInput/> should always set the cursor on the end of a text value
1414
fontSize: 1,
15-
...Platform.select({
16-
web: {
17-
width: '100%',
18-
// Fix iOS Safari aggressive zoom
19-
fontSize: 16,
20-
},
21-
}),
2215
},
2316
});

src/CodeField.styles.web.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import {StyleSheet} from 'react-native';
2+
3+
export const styles = StyleSheet.create({
4+
root: {
5+
justifyContent: 'space-between',
6+
flexDirection: 'row',
7+
},
8+
textInput: {
9+
// <TextInput/> will be rendered above Cells
10+
...StyleSheet.absoluteFillObject,
11+
// Hide <TextInput/> to simulate that user will press into a cell
12+
opacity: 0.015,
13+
// >>>>>> Web only styles <<<<<
14+
width: '100%',
15+
// Fix iOS Safari aggressive zoom
16+
fontSize: 16,
17+
},
18+
});

0 commit comments

Comments
 (0)