What happened?
I'm trying to get metro-plugin-cyclic-dependencies-detector to work. I have multiple import cycles in my app and this plugin is not detecting them and blowing up the way it should.
First off: the docs are wrong about how to set it up with expo. If you do it as suggested in the docs it causes a stack overflow due to unbounded recursion.
This is what I came up with to prevent the infinite recursion.
// Learn more https://docs.expo.io/guides/customizing-metro
const { CyclicDependencies } = require('@rnx-kit/metro-plugin-cyclic-dependencies-detector');
const { getDefaultConfig } = require('expo/metro-config');
/** @type {import('expo/metro-config').MetroConfig} */
const config = getDefaultConfig(__dirname);
const expoSerializer = config.serializer.customSerializer;
config.serializer.customSerializer = async (entryPoint, preModules, graph, options) => {
CyclicDependencies({
throwOnError: true,
})(entryPoint, preModules, graph, options);
return await expoSerializer(entryPoint, preModules, graph, options);
};
module.exports = config;
Affected Package
@rnx-kit/metro-plugin-cyclic-dependencies-detector
Version
2.0.0
Which platforms are you seeing this issue on?
System Information
❯ npx react-native info
⚠️ react-native depends on @react-native-community/cli for cli commands. To fix update your package.json to include:
"devDependencies": {
"@react-native-community/cli": "latest",
}
Steps to Reproduce
- Use my metro config above in an expo project
- Introduce a cyclic dependency between 2 modules.
- Run the bundler and see that it doesn't fail.
Code of Conduct
What happened?
I'm trying to get
metro-plugin-cyclic-dependencies-detectorto work. I have multiple import cycles in my app and this plugin is not detecting them and blowing up the way it should.First off: the docs are wrong about how to set it up with expo. If you do it as suggested in the docs it causes a stack overflow due to unbounded recursion.
This is what I came up with to prevent the infinite recursion.
Affected Package
@rnx-kit/metro-plugin-cyclic-dependencies-detector
Version
2.0.0
Which platforms are you seeing this issue on?
System Information
Steps to Reproduce
Code of Conduct