Skip to content

Commit

Permalink
fix: deprecated babel plugins issue fixed (#44416)
Browse files Browse the repository at this point in the history
Summary:
In this pr, I updated the deprecated babel-plugins with their new library. When you enter the npm page of the relevant plugins, it is recommended to implement new packages instead of the deprecated package.
For example :

<img width="1305" alt="Screenshot 2024-05-05 at 17 50 16" src="https://github.com/facebook/react-native/assets/113903710/a58fdac3-79db-4b53-98bd-4c5325a1e560">

## Motivation:

We use the react-native package in our project and aim to upgrade pnpm to the latest version. First, we wanted to clear deprecated warnings. Babel plugin deprecated warnings were caused by the react-native package, so I created this pull request.
Deprecation Warnings from package installing :

<img width="581" alt="Screenshot 2024-05-05 at 17 53 05" src="https://github.com/facebook/react-native/assets/113903710/9c5859a5-f194-43ab-ae35-417dfaacebab">

## Changelog:

[GENERAL][FIXED] - Replace deprecated babel-plugin libraries to fix deprecation warnings on installation

Pull Request resolved: #44416

Test Plan: CI should pass

Reviewed By: huntie

Differential Revision: D57056843

Pulled By: robhogan

fbshipit-source-id: b75b329bbc2105c31da85e861ef71ffdcbbb0623
  • Loading branch information
kaganece authored and facebook-github-bot committed May 8, 2024
1 parent fd29950 commit 6213b2a
Show file tree
Hide file tree
Showing 6 changed files with 296 additions and 44 deletions.
16 changes: 8 additions & 8 deletions packages/react-native-babel-preset/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
"license": "MIT",
"dependencies": {
"@babel/core": "^7.20.0",
"@babel/plugin-proposal-async-generator-functions": "^7.0.0",
"@babel/plugin-proposal-class-properties": "^7.18.0",
"@babel/plugin-transform-async-generator-functions": "^7.24.3",
"@babel/plugin-transform-class-properties": "^7.24.1",
"@babel/plugin-proposal-export-default-from": "^7.0.0",
"@babel/plugin-proposal-logical-assignment-operators": "^7.18.0",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.18.0",
"@babel/plugin-proposal-numeric-separator": "^7.0.0",
"@babel/plugin-proposal-object-rest-spread": "^7.20.0",
"@babel/plugin-proposal-optional-catch-binding": "^7.0.0",
"@babel/plugin-proposal-optional-chaining": "^7.20.0",
"@babel/plugin-transform-logical-assignment-operators": "^7.24.1",
"@babel/plugin-transform-nullish-coalescing-operator": "^7.24.1",
"@babel/plugin-transform-numeric-separator": "^7.24.1",
"@babel/plugin-transform-object-rest-spread": "^7.24.5",
"@babel/plugin-transform-optional-catch-binding": "^7.24.1",
"@babel/plugin-transform-optional-chaining": "^7.24.5",
"@babel/plugin-syntax-dynamic-import": "^7.8.0",
"@babel/plugin-syntax-export-default-from": "^7.0.0",
"@babel/plugin-syntax-flow": "^7.18.0",
Expand Down
16 changes: 8 additions & 8 deletions packages/react-native-babel-preset/src/configs/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const defaultPlugins = [
[require('@babel/plugin-syntax-flow')],
[require('babel-plugin-transform-flow-enums')],
[require('@babel/plugin-transform-block-scoping')],
[require('@babel/plugin-proposal-class-properties'), {loose}],
[require('@babel/plugin-transform-class-properties'), {loose}],
[require('@babel/plugin-transform-private-methods'), {loose}],
[require('@babel/plugin-transform-private-property-in-object'), {loose}],
[require('@babel/plugin-syntax-dynamic-import')],
Expand Down Expand Up @@ -95,11 +95,11 @@ const getPreset = (src, options) => {
require('@babel/plugin-transform-shorthand-properties'),
]);
extraPlugins.push([
require('@babel/plugin-proposal-optional-catch-binding'),
require('@babel/plugin-transform-optional-catch-binding'),
]);
extraPlugins.push([require('@babel/plugin-transform-function-name')]);
extraPlugins.push([require('@babel/plugin-transform-literals')]);
extraPlugins.push([require('@babel/plugin-proposal-numeric-separator')]);
extraPlugins.push([require('@babel/plugin-transform-numeric-separator')]);
extraPlugins.push([require('@babel/plugin-transform-sticky-regex')]);
} else {
extraPlugins.push([
Expand All @@ -116,15 +116,15 @@ const getPreset = (src, options) => {
extraPlugins.push(
[require('@babel/plugin-transform-spread')],
[
require('@babel/plugin-proposal-object-rest-spread'),
require('@babel/plugin-transform-object-rest-spread'),
// Assume no dependence on getters or evaluation order. See https://github.com/babel/babel/pull/11520
{loose: true, useBuiltIns: true},
],
);
}
if (isNull || src.indexOf('async') !== -1) {
extraPlugins.push([
require('@babel/plugin-proposal-async-generator-functions'),
require('@babel/plugin-transform-async-generator-functions'),
]);
extraPlugins.push([require('@babel/plugin-transform-async-to-generator')]);
}
Expand All @@ -137,13 +137,13 @@ const getPreset = (src, options) => {
}
if (!isHermes && (isNull || src.indexOf('?.') !== -1)) {
extraPlugins.push([
require('@babel/plugin-proposal-optional-chaining'),
require('@babel/plugin-transform-optional-chaining'),
{loose: true},
]);
}
if (!isHermes && (isNull || src.indexOf('??') !== -1)) {
extraPlugins.push([
require('@babel/plugin-proposal-nullish-coalescing-operator'),
require('@babel/plugin-transform-nullish-coalescing-operator'),
{loose: true},
]);
}
Expand All @@ -155,7 +155,7 @@ const getPreset = (src, options) => {
src.indexOf('&&=') !== -1)
) {
extraPlugins.push([
require('@babel/plugin-proposal-logical-assignment-operators'),
require('@babel/plugin-transform-logical-assignment-operators'),
{loose: true},
]);
}
Expand Down
8 changes: 4 additions & 4 deletions packages/react-native-codegen-typescript-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
},
"devDependencies": {
"@babel/core": "^7.20.0",
"@babel/plugin-proposal-class-properties": "^7.18.0",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.18.0",
"@babel/plugin-proposal-object-rest-spread": "^7.20.0",
"@babel/plugin-proposal-optional-chaining": "^7.20.0",
"@babel/plugin-transform-class-properties": "^7.24.1",
"@babel/plugin-transform-nullish-coalescing-operator": "^7.24.1",
"@babel/plugin-transform-object-rest-spread": "^7.24.5",
"@babel/plugin-transform-optional-chaining": "^7.24.5",
"@babel/plugin-syntax-dynamic-import": "^7.8.0",
"@babel/plugin-transform-async-to-generator": "^7.20.0",
"@babel/plugin-transform-destructuring": "^7.20.0",
Expand Down
8 changes: 4 additions & 4 deletions packages/react-native-codegen/.babelrc
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"plugins": [
"@babel/plugin-proposal-object-rest-spread",
"@babel/plugin-transform-object-rest-spread",
"@babel/plugin-transform-async-to-generator",
"@babel/plugin-transform-destructuring",
"@babel/plugin-transform-flow-strip-types",
"@babel/plugin-syntax-dynamic-import",
"@babel/plugin-proposal-class-properties",
"@babel/plugin-proposal-nullish-coalescing-operator",
"@babel/plugin-proposal-optional-chaining"
"@babel/plugin-transform-class-properties",
"@babel/plugin-transform-nullish-coalescing-operator",
"@babel/plugin-transform-optional-chaining"
]
}
8 changes: 4 additions & 4 deletions packages/react-native-codegen/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@
},
"devDependencies": {
"@babel/core": "^7.20.0",
"@babel/plugin-proposal-class-properties": "^7.18.0",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.18.0",
"@babel/plugin-proposal-object-rest-spread": "^7.20.0",
"@babel/plugin-proposal-optional-chaining": "^7.20.0",
"@babel/plugin-transform-class-properties": "^7.24.1",
"@babel/plugin-transform-nullish-coalescing-operator": "^7.24.1",
"@babel/plugin-transform-object-rest-spread": "^7.24.5",
"@babel/plugin-transform-optional-chaining": "^7.24.5",
"@babel/plugin-syntax-dynamic-import": "^7.8.0",
"@babel/plugin-transform-async-to-generator": "^7.20.0",
"@babel/plugin-transform-destructuring": "^7.20.0",
Expand Down

0 comments on commit 6213b2a

Please sign in to comment.