mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
e1998806b7
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/38795 ## Context RFC: Decoupling Flipper from React Native core: https://github.com/react-native-community/discussions-and-proposals/pull/641 ## Changes Inits new package `react-native/community-cli-plugin`. This migrates [`react-native-community/cli-plugin-metro`](https://github.com/react-native-community/cli/tree/main/packages/cli-plugin-metro) into the React Native repo, to enable faster iteration by the React Native core team. Specifically: - This package contains several `metro` dependencies, which when removed from CLI will no longer require us to ship new CLI releases to get Metro patches and features to users. - This package contains the `start`, `bundle`, and `ram-bundle` commands (central to the React Native development experience), for which we have incoming debugging-related changes. - This package now **only** exports commands to be attached via a RN CLI plugin. With this move, we're aiming to **internalise** the default implementations of these dev commands within React Native — other RN CLI plugins can continue to override these, but must do so wholesale. (See also the recent fix for this: https://github.com/react-native-community/cli/pull/1999.) In V15: - (Microsoft feedback) Re-export `unstable_buildBundleWithConfig`, marking as unstable. This gives us a time buffer to consider how we repackage this functionality in future. The package source has been converted from TypeScript to Flow, with a number of new `flow-typed/` defs added to meet type coverage requirements. ## To dos - For now, we aren't removing the existing [`react-native-community/cli-plugin-metro`](https://github.com/react-native-community/cli/tree/main/packages/cli-plugin-metro) source — until later PRs consolidate this move by changing dependencies in the `react-native` package. - **Exported API is reduced!**: I'm working with szymonrybczak to decouple references from RN CLI packages https://github.com/react-native-community/cli/pull/2021. Changelog: [Internal] Reviewed By: motiz88 Differential Revision: D46801501 fbshipit-source-id: 7f6b72941a69f487fb437768cdba125a9aa3418d
73 lines
1.5 KiB
JavaScript
73 lines
1.5 KiB
JavaScript
/**
|
|
* 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.
|
|
*
|
|
* @flow
|
|
* @format
|
|
* @oncall react_native
|
|
*/
|
|
|
|
/*::
|
|
import type {BabelCoreOptions} from '@babel/core';
|
|
|
|
export type BuildOptions = $ReadOnly<{
|
|
target: 'node',
|
|
}>;
|
|
|
|
export type BuildConfig = $ReadOnly<{
|
|
packages: $ReadOnly<{[packageName: string]: BuildOptions}>,
|
|
}>;
|
|
*/
|
|
|
|
const TARGET_NODE_VERSION = '18';
|
|
|
|
const buildConfig /*: BuildConfig */ = {
|
|
// The packages to include for build and their build options
|
|
packages: {
|
|
'community-cli-plugin': {target: 'node'},
|
|
'dev-middleware': {target: 'node'},
|
|
},
|
|
};
|
|
|
|
function getBabelConfig(
|
|
packageName /*: $Keys<BuildConfig['packages']> */,
|
|
) /*: BabelCoreOptions */ {
|
|
const {target} = buildConfig.packages[packageName];
|
|
|
|
switch (target) {
|
|
case 'node':
|
|
return {
|
|
presets: [
|
|
'@babel/preset-flow',
|
|
[
|
|
'@babel/preset-env',
|
|
{
|
|
targets: {
|
|
node: TARGET_NODE_VERSION,
|
|
},
|
|
},
|
|
],
|
|
],
|
|
plugins: [
|
|
[
|
|
'transform-define',
|
|
{
|
|
'process.env.BUILD_EXCLUDE_BABEL_REGISTER': true,
|
|
},
|
|
],
|
|
[
|
|
'minify-dead-code-elimination',
|
|
{keepFnName: true, keepFnArgs: true, keepClassName: true},
|
|
],
|
|
],
|
|
};
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
buildConfig,
|
|
getBabelConfig,
|
|
};
|