Skip to content

Commit

Permalink
Rename metro-react-native-babel-preset to @react-native/babel-preset
Browse files Browse the repository at this point in the history
Summary:
This renames `metro-react-native-babel-preset` package to `react-native/babel-preset`. It also updates references in packages that depend on it.
There are many packages in `fbsource` that depend on some very old versions of `metro-react-native-babel-preset` (like 0.5x.x, 0.6x.x), I didn't touch those.
There are also some packages that keep dependency on `metro-react-native-babel-preset` somewhat up to date:
- [archon](https://www.internalfb.com/code/fbsource/[5ee654840cb5ae29e69d69176e5f212a18646330]/xplat/archon/package.json?lines=156)
- [react-native-toolkit-video-tools/example](https://www.internalfb.com/code/fbsource/[eb67f25aecacd693b4abdcd5774d6d17c90f4c2b]/xplat/npe/libraries/npe/nativemodule/react-native-toolkit-video-tools/example/package.json?lines=21)
- [ReactNativeFlipperExample/package.json](https://www.internalfb.com/code/fbsource/[eb67f25aecacd693b4abdcd5774d6d17c90f4c2b]/xplat/sonar/react-native/ReactNativeFlipperExample/package.json?lines=25)
I'll notify the code owners.

Changelog: [General][Changed] - Rename metro-react-native-babel-preset to react-native/babel-preset

bypass-github-export-checks

Differential Revision: https://internalfb.com/D46559034

fbshipit-source-id: 84b26bc583476da3d204df938aacad5d280ac950
  • Loading branch information
dmitry rykun authored and facebook-github-bot committed Jul 6, 2023
1 parent 6516541 commit 86bcc8e
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"presets": [
"module:metro-react-native-babel-preset"
"module:@react-native/babel-preset"
],
"plugins": [
"babel-plugin-transform-flow-enums"
Expand Down
10 changes: 5 additions & 5 deletions packages/react-native-babel-preset/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# metro-react-native-babel-preset
# @react-native/babel-preset

Babel presets for [React Native](https://reactnative.dev) applications. React Native itself uses this Babel preset by default when transforming your app's source code.

Expand All @@ -10,18 +10,18 @@ As mentioned above, you only need to use this preset if you are writing a custom

### Installation

Install `metro-react-native-babel-preset` in your app:
Install `@react-native/babel-preset` in your app:

with `npm`:

```sh
npm i metro-react-native-babel-preset --save-dev
npm i @react-native/babel-preset --save-dev
```

or with `yarn`:

```sh
yarn add -D metro-react-native-babel-preset
yarn add -D @react-native/babel-preset
```

### Configuring Babel
Expand All @@ -30,7 +30,7 @@ Then, create a file called `babel.config.js` in your project's root directory. T

```
{
"presets": ["module:metro-react-native-babel-preset"]
"presets": ["module:@react-native/babel-preset"]
}
```

Expand Down
6 changes: 3 additions & 3 deletions packages/react-native-babel-preset/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "metro-react-native-babel-preset",
"version": "0.76.7",
"name": "@react-native/babel-preset",
"version": "0.73.3",
"description": "Babel preset for React Native applications",
"main": "src/index.js",
"repository": {
"type": "git",
"url": "[email protected]:facebook/metro.git"
"url": "[email protected]:facebook/react-native.git"
},
"scripts": {
"prepare-release": "test -d lib && mv src src.real && mv lib src",
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native-babel-transformer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
"license": "MIT",
"dependencies": {
"@babel/core": "^7.20.0",
"@react-native/babel-preset": "*",
"babel-preset-fbjs": "^3.4.0",
"hermes-parser": "0.14.0",
"metro-react-native-babel-preset": "0.76.7",
"nullthrows": "^1.1.1"
},
"devDependencies": {
Expand Down
6 changes: 3 additions & 3 deletions packages/react-native-babel-transformer/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const {parseSync, transformFromAstSync} = require('@babel/core');
const inlineRequiresPlugin = require('babel-preset-fbjs/plugins/inline-requires');
const crypto = require('crypto');
const fs = require('fs');
const makeHMRConfig = require('metro-react-native-babel-preset/src/configs/hmr');
const makeHMRConfig = require('@react-native/babel-preset/src/configs/hmr');
const nullthrows = require('nullthrows');
const path = require('path');

Expand All @@ -36,7 +36,7 @@ const cacheKeyParts = [
require('babel-preset-fbjs/package.json').version,
];

// TS detection conditions copied from metro-react-native-babel-preset
// TS detection conditions copied from @react-native/babel-preset
function isTypeScriptSource(fileName /*: string */) {
return !!fileName && fileName.endsWith('.ts');
}
Expand Down Expand Up @@ -110,7 +110,7 @@ const getBabelRC = (function () {
// $FlowFixMe[incompatible-use] `presets` is missing in null or undefined.
babelRC.presets = [
[
require('metro-react-native-babel-preset'),
require('@react-native/babel-preset'),
{
projectRoot,
...presetOptions,
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/template/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
presets: ['module:@react-native/babel-preset'],
};
2 changes: 1 addition & 1 deletion packages/react-native/template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"@babel/core": "^7.20.0",
"@babel/preset-env": "^7.20.0",
"@babel/runtime": "^7.20.0",
"@react-native/babel-preset": "^0.73.3",
"@react-native/eslint-config": "^0.73.0",
"@react-native/metro-config": "^0.73.0",
"@react-native/typescript-config": "^0.73.0",
Expand All @@ -25,7 +26,6 @@
"babel-jest": "^29.2.1",
"eslint": "^8.19.0",
"jest": "^29.2.1",
"metro-react-native-babel-preset": "0.76.7",
"prettier": "2.8.8",
"react-test-renderer": "18.2.0",
"typescript": "5.0.4"
Expand Down
2 changes: 1 addition & 1 deletion packages/rn-tester/.babelrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"presets": [
"module:metro-react-native-babel-preset"
"module:@react-native/babel-preset"
],
"plugins": [
"babel-plugin-transform-flow-enums"
Expand Down
45 changes: 45 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6892,6 +6892,51 @@ [email protected]:
babel-plugin-transform-flow-enums "^0.0.2"
react-refresh "^0.4.0"

[email protected]:
version "0.76.7"
resolved "https://registry.yarnpkg.com/metro-react-native-babel-preset/-/metro-react-native-babel-preset-0.76.7.tgz#dfe15c040d0918147a8b0e9f530d558287acbb54"
integrity sha512-R25wq+VOSorAK3hc07NW0SmN8z9S/IR0Us0oGAsBcMZnsgkbOxu77Mduqf+f4is/wnWHc5+9bfiqdLnaMngiVw==
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-proposal-export-default-from" "^7.0.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-syntax-dynamic-import" "^7.8.0"
"@babel/plugin-syntax-export-default-from" "^7.0.0"
"@babel/plugin-syntax-flow" "^7.18.0"
"@babel/plugin-syntax-nullish-coalescing-operator" "^7.0.0"
"@babel/plugin-syntax-optional-chaining" "^7.0.0"
"@babel/plugin-transform-arrow-functions" "^7.0.0"
"@babel/plugin-transform-async-to-generator" "^7.20.0"
"@babel/plugin-transform-block-scoping" "^7.0.0"
"@babel/plugin-transform-classes" "^7.0.0"
"@babel/plugin-transform-computed-properties" "^7.0.0"
"@babel/plugin-transform-destructuring" "^7.20.0"
"@babel/plugin-transform-flow-strip-types" "^7.20.0"
"@babel/plugin-transform-function-name" "^7.0.0"
"@babel/plugin-transform-literals" "^7.0.0"
"@babel/plugin-transform-modules-commonjs" "^7.0.0"
"@babel/plugin-transform-named-capturing-groups-regex" "^7.0.0"
"@babel/plugin-transform-parameters" "^7.0.0"
"@babel/plugin-transform-react-display-name" "^7.0.0"
"@babel/plugin-transform-react-jsx" "^7.0.0"
"@babel/plugin-transform-react-jsx-self" "^7.0.0"
"@babel/plugin-transform-react-jsx-source" "^7.0.0"
"@babel/plugin-transform-runtime" "^7.0.0"
"@babel/plugin-transform-shorthand-properties" "^7.0.0"
"@babel/plugin-transform-spread" "^7.0.0"
"@babel/plugin-transform-sticky-regex" "^7.0.0"
"@babel/plugin-transform-typescript" "^7.5.0"
"@babel/plugin-transform-unicode-regex" "^7.0.0"
"@babel/template" "^7.0.0"
babel-plugin-transform-flow-enums "^0.0.2"
react-refresh "^0.4.0"

[email protected]:
version "0.76.2"
resolved "https://registry.yarnpkg.com/metro-react-native-babel-transformer/-/metro-react-native-babel-transformer-0.76.2.tgz#84865806bcbd9376db8190c33f2b7cd178fa342b"
Expand Down

0 comments on commit 86bcc8e

Please sign in to comment.