@rnx-kit/metro-plugin-cyclic-dependencies-detector
TypeScript icon, indicating that this package has built-in type declarations

1.1.2 • Public • Published

@rnx-kit/metro-plugin-cyclic-dependencies-detector

Build npm version

@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.

Readme

Keywords

none

Package Sidebar

Install

npm i @rnx-kit/metro-plugin-cyclic-dependencies-detector

Weekly Downloads

18,045

Version

1.1.2

License

MIT

Unpacked Size

12.9 kB

Total Files

10

Last publish

Collaborators

  • kelset
  • hansenyy
  • jasonvmorse
  • acoates
  • rnbot
  • tido64
  • rnsdkbot