Skip to content

Commit a14637f

Browse files
committed
docs(metro-plugin-cyclic-dependencies-detector): fix Expo example
1 parent 72a98f6 commit a14637f

2 files changed

Lines changed: 14 additions & 6 deletions

File tree

.changeset/shiny-snakes-behave.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

packages/metro-plugin-cyclic-dependencies-detector/README.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,15 @@ directly in your `metro.config.js`. This is useful if you are using Expo which
3636
uses its own custom serializer:
3737

3838
```js
39+
const {
40+
CyclicDependencies,
41+
} = require("@rnx-kit/metro-plugin-cyclic-dependencies-detector");
3942
const { getDefaultConfig } = require("expo/metro-config");
4043

4144
/** @type {import('expo/metro-config').MetroConfig} */
4245
const config = getDefaultConfig(__dirname);
4346

47+
const expoSerializer = config.serializer.customSerializer;
4448
config.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

6160
module.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

Comments
 (0)