Skip to content

Commit ce43ec1

Browse files
huntiemeta-codesync[bot]
authored andcommitted
Drop legacy cli-server-api reference in dev server
Summary: 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] Differential Revision: D113412986
1 parent e8a74d5 commit ce43ec1

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
@@ -70,23 +70,12 @@ export default function loadCommunityMiddleware(): DevServerMiddlewareFactory {
7070
try {
7171
// `@react-native-community/cli` is an optional peer dependency of this
7272
// package, and should be a dev dependency of the host project (via the
73-
// community template's package.json).
74-
const communityCliPath = require.resolve('@react-native-community/cli');
75-
76-
// Until https://github.com/react-native-community/cli/pull/2605 lands,
77-
// we need to find `@react-native-community/cli-server-api` via
78-
// `@react-native-community/cli`. Once that lands, we can simply
79-
// require('@react-native-community/cli').
80-
const communityCliServerApiPath = require.resolve(
81-
'@react-native-community/cli-server-api',
82-
{paths: [communityCliPath]},
83-
);
84-
// $FlowFixMe[unsupported-syntax] dynamic import
85-
return require(communityCliServerApiPath)
86-
.createDevServerMiddleware as CreateDevServerMiddleware;
73+
// community template's package.json). Required dynamically so its types
74+
// aren't needed at build time.
75+
return require('@react-native-community/cli').createDevServerMiddleware;
8776
} catch {
88-
debug(`⚠️ Unable to find @react-native-community/cli-server-api
89-
Starting the server without the community middleware.`);
77+
console.warn(`⚠️ Unable to find @react-native-community/cli.
78+
Starting dev server without community middleware endpoints - some functionality may be broken.`);
9079
return communityMiddlewareFallback;
9180
}
9281
}

0 commit comments

Comments
 (0)