Skip to content

Commit 52218e6

Browse files
huntiemeta-codesync[bot]
authored andcommitted
Drop legacy cli-server-api reference in dev server (#57653)
Summary: Pull Request resolved: #57653 Actions TODO comment dependant on react-native-community/cli#2605 (landed). This drops our local dependency on `react-native-community/cli-server-api` Flow types, as well as avoiding this transient dependency in end user projects. **Other changes** - Promote `debug` log to a user-facing `warn` — several features in RN will break/degrade in this case and we want to flag explicitly. Changelog: [Internal] Reviewed By: cortinico Differential Revision: D113412986
1 parent f539d9a commit 52218e6

2 files changed

Lines changed: 5 additions & 60 deletions

File tree

flow-typed/npm/@react-native-community/cli-server-api_v19.x.x.js

Lines changed: 0 additions & 44 deletions
This file was deleted.

packages/community-cli-plugin/src/dev-server/loadCommunityMiddleware.js

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
import type {Server} from 'connect';
1212
import type {TerminalReportableEvent} from 'metro';
1313

14-
const debug = require('debug')('ReactNative:CommunityCliPlugin');
15-
1614
type DevServerMiddlewareFactory = (params: {
1715
host?: string,
1816
port: number,
@@ -73,21 +71,12 @@ export default function loadCommunityMiddleware(): DevServerMiddlewareFactory {
7371
// `@react-native-community/cli` is an optional peer dependency of this
7472
// package, and should be a dev dependency of the host project (via the
7573
// community template's package.json).
76-
const communityCliPath = require.resolve('@react-native-community/cli');
77-
78-
// Until https://github.com/react-native-community/cli/pull/2605 lands,
79-
// we need to find `@react-native-community/cli-server-api` via
80-
// `@react-native-community/cli`. Once that lands, we can simply
81-
// require('@react-native-community/cli').
82-
const communityCliServerApiPath = require.resolve(
83-
'@react-native-community/cli-server-api',
84-
{paths: [communityCliPath]},
85-
);
86-
// $FlowFixMe[unsupported-syntax] dynamic import
87-
return require(communityCliServerApiPath).createDevServerMiddleware;
74+
// $FlowFixMe[prop-missing]
75+
// $FlowFixMe[untyped-import]
76+
return require('@react-native-community/cli').createDevServerMiddleware;
8877
} catch {
89-
debug(`⚠️ Unable to find @react-native-community/cli-server-api
90-
Starting the server without the community middleware.`);
78+
console.warn(`⚠️ Unable to find @react-native-community/cli.
79+
Starting dev server without community middleware endpoints - some functionality may be broken.`);
9180
return communityMiddlewareFallback;
9281
}
9382
}

0 commit comments

Comments
 (0)