-
Notifications
You must be signed in to change notification settings - Fork 117
@rnx-kit/metro-config causes warning on react-native 0.72 #2481
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't workingfeature: metroThis is related to MetroThis is related to MetroupstreamThis should be fixed/reported upstreamThis should be fixed/reported upstream
Description
What happened?
In a vanilla project with react-native 0.72 and only @rnx-kit/metro-config, react-native bundle outputs the following warning:
warn From React Native 0.72, your metro.config.js file should extend'@react-native/metro-config'. Please see the React Native 0.72 changelog, or copy the template at:
https://github.com/facebook/react-native/blob/main/packages/react-native/template/metro.config.js
@rnx-kit/metro-config correctly loads defaults from @react-native/metro-config, but the CLI cannot know this. This is currently how it checks whether someone is loading defaults from the correct package, by scanning metro.config.js for any mention of "@react-native/metro-config": https://github.com/react-native-community/cli/blob/3569633e1bbda4858195feb8537d7b9969b2040e/packages/cli-plugin-metro/src/tools/loadMetroConfig.ts#L100-L104
As a workaround, we can simply mention the package in a comment like below:
diff --git a/packages/test-app/metro.config.js b/packages/test-app/metro.config.js
index 0a8bd04a..8a976d89 100644
--- a/packages/test-app/metro.config.js
+++ b/packages/test-app/metro.config.js
@@ -1,3 +1,6 @@
+// Just mentioning "@react-native/metro-config" here to prevent CLI from warning
+// about missing `@rnx-kit/metro-config` and falling back to internal defaults.
+
const { exclusionList, makeMetroConfig } = require("@rnx-kit/metro-config");
const MetroSymlinksResolver = require("@rnx-kit/metro-resolver-symlinks");Affected Package
@rnx-kit/metro-config
Version
1.3.7
Which platforms are you seeing this issue on?
- Android
- iOS
- macOS
- Windows
System Information
n/a
Steps to Reproduce
- Bump react-native to 0.72 (and make sure metro 0.76 is used)
- In
packages/test-app, bundle with CLI, e.g.:yarn react-native bundle --entry-file src/index.ts --platform android --dev true --bundle-output dist/main.android.jsbundle --assets-dest dist/res
Code of Conduct
- I agree to follow this project's Code of Conduct
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingfeature: metroThis is related to MetroThis is related to MetroupstreamThis should be fixed/reported upstreamThis should be fixed/reported upstream