-
Notifications
You must be signed in to change notification settings - Fork 24.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move react-native-babel-transformer and react-native-babel-preset fro…
…m Metro to React Native repo (#38228) Summary: X-link: facebook/metro#1024 Pull Request resolved: #38228 Changelog: [General][Changed] - Move react-native-babel-transformer and react-native-babel-preset from Metro to React Native repo. Metro Changelog: **[Breaking]** - Remove `metro-react-native-babel-transformer` and `metro-react-native-babel-preset`, to be published as `react-native/metro-babel-transformer` and `react-native/babel-preset` instead. This diff does the following: - Move `metro/packages/metro-react-native-babel-preset` to `react-native/packages/react-native-babel-preset`. - Rename `metro-react-native-babel-preset` package to `react-native/babel-preset`. - Move `metro/packages/metro-react-native-babel-transformer` to `react-native/packages/react-native-babel-transformer`. - Rename `metro-react-native-babel-transformer` package to `react-native/metro-babel-transformer`. - Upadate dependencies. Reviewed By: robhogan Differential Revision: D46977466 fbshipit-source-id: 07892eb91338b43e37c3b7a137701cfdb7691ee5
- Loading branch information
1 parent
e37e530
commit 985aaa2
Showing
23 changed files
with
860 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
**/__mocks__/ | ||
**/__tests__/ | ||
/build/ | ||
/src.real/ | ||
/types/ | ||
yarn.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# @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. | ||
|
||
If you wish to use a custom Babel configuration by writing a `babel.config.js` file in your project's root directory, you must specify all the plugins necessary to transform your code. React Native does not apply its default Babel configuration in this case. So, to make your life easier, you can use this preset to get the default configuration and then specify more plugins that run before it. | ||
|
||
## Usage | ||
|
||
As mentioned above, you only need to use this preset if you are writing a custom `babel.config.js` file. | ||
|
||
### Installation | ||
|
||
Install `@react-native/babel-preset` in your app: | ||
|
||
with `npm`: | ||
|
||
```sh | ||
npm i @react-native/babel-preset --save-dev | ||
``` | ||
|
||
or with `yarn`: | ||
|
||
```sh | ||
yarn add -D @react-native/babel-preset | ||
``` | ||
|
||
### Configuring Babel | ||
|
||
Then, create a file called `babel.config.js` in your project's root directory. The existence of this `babel.config.js` file will tell React Native to use your custom Babel configuration instead of its own. Then load this preset: | ||
|
||
``` | ||
{ | ||
"presets": ["module:@react-native/babel-preset"] | ||
} | ||
``` | ||
|
||
You can further customize your Babel configuration by specifying plugins and other options. See [Babel's `babel.config.js` documentation](https://babeljs.io/docs/en/config-files/) to learn more. | ||
|
||
## Help and Support | ||
|
||
If you get stuck configuring Babel, please ask a question on Stack Overflow or find a consultant for help. If you discover a bug, please open up an issue. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @format | ||
* @oncall react_native | ||
*/ | ||
|
||
export * from './src'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
{ | ||
"name": "@react-native/babel-preset", | ||
"version": "0.73.14", | ||
"description": "Babel preset for React Native applications", | ||
"exports": { | ||
".": "./src/index.js", | ||
"./package.json": "./package.json" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git@github.com:facebook/react-native.git" | ||
}, | ||
"keywords": [ | ||
"babel", | ||
"preset", | ||
"react-native" | ||
], | ||
"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-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" | ||
}, | ||
"peerDependencies": { | ||
"@babel/core": "*" | ||
}, | ||
"engines": { | ||
"node": ">=18" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @format | ||
* @oncall react_native | ||
*/ | ||
|
||
'use strict'; | ||
|
||
module.exports = function () { | ||
return { | ||
plugins: [require('react-refresh/babel')], | ||
}; | ||
}; |
93 changes: 93 additions & 0 deletions
93
packages/react-native-babel-preset/src/configs/lazy-imports.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @format | ||
* @oncall react_native | ||
*/ | ||
|
||
// This is the set of modules that React Native publicly exports and that we | ||
// want to require lazily. Keep this list in sync with | ||
// react-native/index.js (though having extra entries here is fairly harmless). | ||
|
||
'use strict'; | ||
|
||
module.exports = new Set([ | ||
'AccessibilityInfo', | ||
'ActivityIndicator', | ||
'Button', | ||
'DatePickerIOS', | ||
'DrawerLayoutAndroid', | ||
'FlatList', | ||
'Image', | ||
'ImageBackground', | ||
'InputAccessoryView', | ||
'KeyboardAvoidingView', | ||
'Modal', | ||
'Pressable', | ||
'ProgressBarAndroid', | ||
'ProgressViewIOS', | ||
'SafeAreaView', | ||
'ScrollView', | ||
'SectionList', | ||
'Slider', | ||
'Switch', | ||
'RefreshControl', | ||
'StatusBar', | ||
'Text', | ||
'TextInput', | ||
'Touchable', | ||
'TouchableHighlight', | ||
'TouchableNativeFeedback', | ||
'TouchableOpacity', | ||
'TouchableWithoutFeedback', | ||
'View', | ||
'VirtualizedList', | ||
'VirtualizedSectionList', | ||
|
||
// APIs | ||
'ActionSheetIOS', | ||
'Alert', | ||
'Animated', | ||
'Appearance', | ||
'AppRegistry', | ||
'AppState', | ||
'AsyncStorage', | ||
'BackHandler', | ||
'Clipboard', | ||
'DeviceInfo', | ||
'Dimensions', | ||
'Easing', | ||
'ReactNative', | ||
'I18nManager', | ||
'InteractionManager', | ||
'Keyboard', | ||
'LayoutAnimation', | ||
'Linking', | ||
'LogBox', | ||
'NativeEventEmitter', | ||
'PanResponder', | ||
'PermissionsAndroid', | ||
'PixelRatio', | ||
'PushNotificationIOS', | ||
'Settings', | ||
'Share', | ||
'StyleSheet', | ||
'Systrace', | ||
'ToastAndroid', | ||
'TVEventHandler', | ||
'UIManager', | ||
'ReactNative', | ||
'UTFSequence', | ||
'Vibration', | ||
|
||
// Plugins | ||
'RCTDeviceEventEmitter', | ||
'RCTNativeAppEventEmitter', | ||
'NativeModules', | ||
'Platform', | ||
'processColor', | ||
'requireNativeComponent', | ||
]); |
Oops, something went wrong.