зеркало из https://github.com/microsoft/rnx-kit.git
57013d2191
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Tommy Nguyen <4123478+tido64@users.noreply.github.com> |
||
---|---|---|
.. | ||
src | ||
test | ||
CHANGELOG.md | ||
README.md | ||
eslint.config.js | ||
package.json | ||
tsconfig.json |
README.md
@rnx-kit/metro-plugin-cyclic-dependencies-detector
@rnx-kit/metro-plugin-cyclic-dependencies-detector
detects cyclic import
chains that may cause issues in your bundle.
Usage
Import and add the plugin to MetroSerializer
in your metro.config.js
, and
optionally configure it to your liking:
const { makeMetroConfig } = require("@rnx-kit/metro-config");
+const {
+ CyclicDependencies,
+} = require("@rnx-kit/metro-plugin-cyclic-dependencies-detector");
+const { MetroSerializer } = require("@rnx-kit/metro-serializer");
module.exports = makeMetroConfig({
serializer: {
+ customSerializer: MetroSerializer([
+ CyclicDependencies({
+ includeNodeModules: false,
+ linesOfContext: 1,
+ throwOnError: true,
+ }),
+ ]),
},
});
Options
Key | Type | Default | Description |
---|---|---|---|
includeNodeModules | boolean | false |
Whether to scan node_modules . |
linesOfContext | number | 1 | Number of extra modules to print for context. |
throwOnError | boolean | true |
Whether to throw when cycles are detected. |