Skip to content

Commit 13f4c45

Browse files
yungstersfacebook-github-bot
authored andcommitted
RN: Support Private Methods & Properties (facebook#39318)
Summary: Pull Request resolved: facebook#39318 Updates `react-native/babel-preset` to support private methods and properties. Changelog: [General][Added] Added plugins for private methods and properties to `react-native/babel-preset`. Reviewed By: asiandrummer Differential Revision: D49029339 fbshipit-source-id: b1295ae93ffe88336ba500774f76dbb8ddd43aeb
1 parent 48c297e commit 13f4c45

File tree

3 files changed

+102
-5
lines changed

3 files changed

+102
-5
lines changed

packages/react-native-babel-preset/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
"@babel/plugin-transform-modules-commonjs": "^7.0.0",
4141
"@babel/plugin-transform-named-capturing-groups-regex": "^7.0.0",
4242
"@babel/plugin-transform-parameters": "^7.0.0",
43+
"@babel/plugin-transform-private-methods": "^7.22.5",
44+
"@babel/plugin-transform-private-property-in-object": "^7.22.11",
4345
"@babel/plugin-transform-react-display-name": "^7.0.0",
4446
"@babel/plugin-transform-react-jsx": "^7.0.0",
4547
"@babel/plugin-transform-react-jsx-self": "^7.0.0",

packages/react-native-babel-preset/src/configs/main.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,16 @@ function isTSXSource(fileName) {
2121
return !!fileName && fileName.endsWith('.tsx');
2222
}
2323

24+
// use `this.foo = bar` instead of `this.defineProperty('foo', ...)`
25+
const loose = true;
26+
2427
const defaultPlugins = [
2528
[require('@babel/plugin-syntax-flow')],
2629
[require('babel-plugin-transform-flow-enums')],
2730
[require('@babel/plugin-transform-block-scoping')],
28-
[
29-
require('@babel/plugin-proposal-class-properties'),
30-
// use `this.foo = bar` instead of `this.defineProperty('foo', ...)`
31-
{loose: true},
32-
],
31+
[require('@babel/plugin-proposal-class-properties'), {loose}],
32+
[require('@babel/plugin-transform-private-methods'), {loose}],
33+
[require('@babel/plugin-transform-private-property-in-object'), {loose}],
3334
[require('@babel/plugin-syntax-dynamic-import')],
3435
[require('@babel/plugin-syntax-export-default-from')],
3536
...passthroughSyntaxPlugins,

yarn.lock

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,21 @@
426426
"@babel/helper-skip-transparent-expression-wrappers" "^7.20.0"
427427
"@babel/helper-split-export-declaration" "^7.18.6"
428428

429+
"@babel/helper-create-class-features-plugin@^7.22.11", "@babel/helper-create-class-features-plugin@^7.22.5":
430+
version "7.22.15"
431+
resolved "https://registry.yarnpkg.com/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.22.15.tgz#97a61b385e57fe458496fad19f8e63b63c867de4"
432+
integrity sha512-jKkwA59IXcvSaiK2UN45kKwSC9o+KuoXsBDvHvU/7BecYIp8GQ2UwrVvFgJASUT+hBnwJx6MhvMCuMzwZZ7jlg==
433+
dependencies:
434+
"@babel/helper-annotate-as-pure" "^7.22.5"
435+
"@babel/helper-environment-visitor" "^7.22.5"
436+
"@babel/helper-function-name" "^7.22.5"
437+
"@babel/helper-member-expression-to-functions" "^7.22.15"
438+
"@babel/helper-optimise-call-expression" "^7.22.5"
439+
"@babel/helper-replace-supers" "^7.22.9"
440+
"@babel/helper-skip-transparent-expression-wrappers" "^7.22.5"
441+
"@babel/helper-split-export-declaration" "^7.22.6"
442+
semver "^6.3.1"
443+
429444
"@babel/helper-create-regexp-features-plugin@^7.18.6", "@babel/helper-create-regexp-features-plugin@^7.20.5":
430445
version "7.20.5"
431446
resolved "https://registry.yarnpkg.com/@babel/helper-create-regexp-features-plugin/-/helper-create-regexp-features-plugin-7.20.5.tgz#5ea79b59962a09ec2acf20a963a01ab4d076ccca"
@@ -493,6 +508,13 @@
493508
dependencies:
494509
"@babel/types" "^7.21.0"
495510

511+
"@babel/helper-member-expression-to-functions@^7.22.15", "@babel/helper-member-expression-to-functions@^7.22.5":
512+
version "7.22.15"
513+
resolved "https://registry.yarnpkg.com/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.22.15.tgz#b95a144896f6d491ca7863576f820f3628818621"
514+
integrity sha512-qLNsZbgrNh0fDQBCPocSL8guki1hcPvltGDv/NxvUoABwFq7GkKSu1nRXeJkVZc+wJvne2E0RKQz+2SQrz6eAA==
515+
dependencies:
516+
"@babel/types" "^7.22.15"
517+
496518
"@babel/helper-module-imports@^7.18.6":
497519
version "7.18.6"
498520
resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.18.6.tgz#1e3ebdbbd08aad1437b428c50204db13c5a3ca6e"
@@ -521,11 +543,23 @@
521543
dependencies:
522544
"@babel/types" "^7.18.6"
523545

546+
"@babel/helper-optimise-call-expression@^7.22.5":
547+
version "7.22.5"
548+
resolved "https://registry.yarnpkg.com/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.22.5.tgz#f21531a9ccbff644fdd156b4077c16ff0c3f609e"
549+
integrity sha512-HBwaojN0xFRx4yIvpwGqxiV2tUfl7401jlok564NgB9EHS1y6QT17FmKWm4ztqjeVdXLuC4fSvHc5ePpQjoTbw==
550+
dependencies:
551+
"@babel/types" "^7.22.5"
552+
524553
"@babel/helper-plugin-utils@^7.0.0", "@babel/helper-plugin-utils@^7.10.4", "@babel/helper-plugin-utils@^7.12.13", "@babel/helper-plugin-utils@^7.14.5", "@babel/helper-plugin-utils@^7.16.7", "@babel/helper-plugin-utils@^7.18.6", "@babel/helper-plugin-utils@^7.18.9", "@babel/helper-plugin-utils@^7.19.0", "@babel/helper-plugin-utils@^7.20.2", "@babel/helper-plugin-utils@^7.21.5", "@babel/helper-plugin-utils@^7.8.0", "@babel/helper-plugin-utils@^7.8.3":
525554
version "7.21.5"
526555
resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.21.5.tgz#345f2377d05a720a4e5ecfa39cbf4474a4daed56"
527556
integrity sha512-0WDaIlXKOX/3KfBK/dwP1oQGiPh6rjMkT7HIRv7i5RR2VUMwrx5ZL0dwBkKx7+SW1zwNdgjHd34IMk5ZjTeHVg==
528557

558+
"@babel/helper-plugin-utils@^7.22.5":
559+
version "7.22.5"
560+
resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.22.5.tgz#dd7ee3735e8a313b9f7b05a773d892e88e6d7295"
561+
integrity sha512-uLls06UVKgFG9QD4OeFYLEGteMIAa5kpTPcFL28yuCIIzsf6ZyKZMllKVOCZFhiZ5ptnwX4mtKdWCBE/uT4amg==
562+
529563
"@babel/helper-remap-async-to-generator@^7.18.6":
530564
version "7.22.9"
531565
resolved "https://registry.yarnpkg.com/@babel/helper-remap-async-to-generator/-/helper-remap-async-to-generator-7.22.9.tgz#53a25b7484e722d7efb9c350c75c032d4628de82"
@@ -557,6 +591,15 @@
557591
"@babel/traverse" "^7.20.7"
558592
"@babel/types" "^7.20.7"
559593

594+
"@babel/helper-replace-supers@^7.22.9":
595+
version "7.22.9"
596+
resolved "https://registry.yarnpkg.com/@babel/helper-replace-supers/-/helper-replace-supers-7.22.9.tgz#cbdc27d6d8d18cd22c81ae4293765a5d9afd0779"
597+
integrity sha512-LJIKvvpgPOPUThdYqcX6IXRuIcTkcAub0IaDRGCZH0p5GPUp7PhRU9QVgFcDDd51BaPkk77ZjqFwh6DZTAEmGg==
598+
dependencies:
599+
"@babel/helper-environment-visitor" "^7.22.5"
600+
"@babel/helper-member-expression-to-functions" "^7.22.5"
601+
"@babel/helper-optimise-call-expression" "^7.22.5"
602+
560603
"@babel/helper-simple-access@^7.19.4", "@babel/helper-simple-access@^7.20.2":
561604
version "7.20.2"
562605
resolved "https://registry.yarnpkg.com/@babel/helper-simple-access/-/helper-simple-access-7.20.2.tgz#0ab452687fe0c2cfb1e2b9e0015de07fc2d62dd9"
@@ -571,13 +614,27 @@
571614
dependencies:
572615
"@babel/types" "^7.20.0"
573616

617+
"@babel/helper-skip-transparent-expression-wrappers@^7.22.5":
618+
version "7.22.5"
619+
resolved "https://registry.yarnpkg.com/@babel/helper-skip-transparent-expression-wrappers/-/helper-skip-transparent-expression-wrappers-7.22.5.tgz#007f15240b5751c537c40e77abb4e89eeaaa8847"
620+
integrity sha512-tK14r66JZKiC43p8Ki33yLBVJKlQDFoA8GYN67lWCDCqoL6EMMSuM9b+Iff2jHaM/RRFYl7K+iiru7hbRqNx8Q==
621+
dependencies:
622+
"@babel/types" "^7.22.5"
623+
574624
"@babel/helper-split-export-declaration@^7.18.6":
575625
version "7.18.6"
576626
resolved "https://registry.yarnpkg.com/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.18.6.tgz#7367949bc75b20c6d5a5d4a97bba2824ae8ef075"
577627
integrity sha512-bde1etTx6ZyTmobl9LLMMQsaizFVZrquTEHOqKeQESMKo4PlObf+8+JA25ZsIpZhT/WEd39+vOdLXAFG/nELpA==
578628
dependencies:
579629
"@babel/types" "^7.18.6"
580630

631+
"@babel/helper-split-export-declaration@^7.22.6":
632+
version "7.22.6"
633+
resolved "https://registry.yarnpkg.com/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.22.6.tgz#322c61b7310c0997fe4c323955667f18fcefb91c"
634+
integrity sha512-AsUnxuLhRYsisFiaJwvp1QF+I3KjD5FOxut14q/GzovUe6orHLesW2C7d754kRm53h5gqrz6sFl6sxc4BVtE/g==
635+
dependencies:
636+
"@babel/types" "^7.22.5"
637+
581638
"@babel/helper-string-parser@^7.19.4":
582639
version "7.19.4"
583640
resolved "https://registry.yarnpkg.com/@babel/helper-string-parser/-/helper-string-parser-7.19.4.tgz#38d3acb654b4701a9b77fb0615a96f775c3a9e63"
@@ -593,6 +650,11 @@
593650
resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.19.1.tgz#7eea834cf32901ffdc1a7ee555e2f9c27e249ca2"
594651
integrity sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w==
595652

653+
"@babel/helper-validator-identifier@^7.22.15":
654+
version "7.22.15"
655+
resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.15.tgz#601fa28e4cc06786c18912dca138cec73b882044"
656+
integrity sha512-4E/F9IIEi8WR94324mbDUMo074YTheJmd7eZF5vITTeYchqAi6sYXRLHUVsmkdmY4QjfKTcB2jB7dVP3NaBElQ==
657+
596658
"@babel/helper-validator-identifier@^7.22.5":
597659
version "7.22.5"
598660
resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.5.tgz#9544ef6a33999343c8740fa51350f30eeaaaf193"
@@ -1153,6 +1215,24 @@
11531215
dependencies:
11541216
"@babel/helper-plugin-utils" "^7.20.2"
11551217

1218+
"@babel/plugin-transform-private-methods@^7.22.5":
1219+
version "7.22.5"
1220+
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-private-methods/-/plugin-transform-private-methods-7.22.5.tgz#21c8af791f76674420a147ae62e9935d790f8722"
1221+
integrity sha512-PPjh4gyrQnGe97JTalgRGMuU4icsZFnWkzicB/fUtzlKUqvsWBKEpPPfr5a2JiyirZkHxnAqkQMO5Z5B2kK3fA==
1222+
dependencies:
1223+
"@babel/helper-create-class-features-plugin" "^7.22.5"
1224+
"@babel/helper-plugin-utils" "^7.22.5"
1225+
1226+
"@babel/plugin-transform-private-property-in-object@^7.22.11":
1227+
version "7.22.11"
1228+
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-private-property-in-object/-/plugin-transform-private-property-in-object-7.22.11.tgz#ad45c4fc440e9cb84c718ed0906d96cf40f9a4e1"
1229+
integrity sha512-sSCbqZDBKHetvjSwpyWzhuHkmW5RummxJBVbYLkGkaiTOWGxml7SXt0iWa03bzxFIx7wOj3g/ILRd0RcJKBeSQ==
1230+
dependencies:
1231+
"@babel/helper-annotate-as-pure" "^7.22.5"
1232+
"@babel/helper-create-class-features-plugin" "^7.22.11"
1233+
"@babel/helper-plugin-utils" "^7.22.5"
1234+
"@babel/plugin-syntax-private-property-in-object" "^7.14.5"
1235+
11561236
"@babel/plugin-transform-property-literals@^7.0.0", "@babel/plugin-transform-property-literals@^7.18.6":
11571237
version "7.18.6"
11581238
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-property-literals/-/plugin-transform-property-literals-7.18.6.tgz#e22498903a483448e94e032e9bbb9c5ccbfc93a3"
@@ -1465,6 +1545,15 @@
14651545
"@babel/helper-validator-identifier" "^7.19.1"
14661546
to-fast-properties "^2.0.0"
14671547

1548+
"@babel/types@^7.22.15":
1549+
version "7.22.15"
1550+
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.22.15.tgz#266cb21d2c5fd0b3931e7a91b6dd72d2f617d282"
1551+
integrity sha512-X+NLXr0N8XXmN5ZsaQdm9U2SSC3UbIYq/doL++sueHOTisgZHoKaQtZxGuV2cUPQHMfjKEfg/g6oy7Hm6SKFtA==
1552+
dependencies:
1553+
"@babel/helper-string-parser" "^7.22.5"
1554+
"@babel/helper-validator-identifier" "^7.22.15"
1555+
to-fast-properties "^2.0.0"
1556+
14681557
"@babel/types@^7.22.5":
14691558
version "7.22.5"
14701559
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.22.5.tgz#cd93eeaab025880a3a47ec881f4b096a5b786fbe"
@@ -10166,6 +10255,11 @@ semver@^6.0.0, semver@^6.1.1, semver@^6.1.2, semver@^6.2.0, semver@^6.3.0:
1016610255
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d"
1016710256
integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==
1016810257

10258+
semver@^6.3.1:
10259+
version "6.3.1"
10260+
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4"
10261+
integrity sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==
10262+
1016910263
semver@^7.5.2, semver@^7.5.3, semver@^7.5.4:
1017010264
version "7.5.4"
1017110265
resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.4.tgz#483986ec4ed38e1c6c48c34894a9182dbff68a6e"

0 commit comments

Comments
 (0)