@@ -36,11 +36,15 @@ directly in your `metro.config.js`. This is useful if you are using Expo which
3636uses its own custom serializer:
3737
3838``` js
39+ const {
40+ CyclicDependencies ,
41+ } = require (" @rnx-kit/metro-plugin-cyclic-dependencies-detector" );
3942const { getDefaultConfig } = require (" expo/metro-config" );
4043
4144/** @type {import('expo/metro-config').MetroConfig} */
4245const config = getDefaultConfig (__dirname );
4346
47+ const expoSerializer = config .serializer .customSerializer ;
4448config .serializer .customSerializer = async (
4549 entryPoint,
4650 preModules,
@@ -50,12 +54,7 @@ config.serializer.customSerializer = async (
5054 CyclicDependencies ({
5155 // Options
5256 })(entryPoint, preModules, graph, options);
53- return await config .serializer .customSerializer (
54- entryPoint,
55- preModules,
56- graph,
57- options
58- );
57+ return await expoSerializer (entryPoint, preModules, graph, options);
5958};
6059
6160module .exports = config;
@@ -68,3 +67,10 @@ module.exports = config;
6867| includeNodeModules | boolean | ` false ` | Whether to scan ` node_modules ` . |
6968| linesOfContext | number | 1 | Number of extra modules to print for context. |
7069| throwOnError | boolean | ` true ` | Whether to throw when cycles are detected. |
70+
71+ ## Limitations
72+
73+ - This plugin can only detect cycles that are present in the module graph
74+ generated by Metro. If your project uses file based routing (e.g. Expo
75+ Router), Metro may not include every file in its module graph. Consequently,
76+ this plugin cannot detect cycles outside of the graph.
0 commit comments