Browse Source

dev: add plugin for circular dependency detection

Example run: https://gist.github.com/saghul/e5e12edc108bdedbcbe65a3d7528235f
master
Saúl Ibarra Corretgé 5 years ago
parent
commit
d4d1d0aa70
3 changed files with 15 additions and 0 deletions
  1. 6
    0
      package-lock.json
  2. 1
    0
      package.json
  3. 8
    0
      webpack.config.js

+ 6
- 0
package-lock.json View File

6169
         "safe-buffer": "^5.0.1"
6169
         "safe-buffer": "^5.0.1"
6170
       }
6170
       }
6171
     },
6171
     },
6172
+    "circular-dependency-plugin": {
6173
+      "version": "5.2.0",
6174
+      "resolved": "https://registry.npmjs.org/circular-dependency-plugin/-/circular-dependency-plugin-5.2.0.tgz",
6175
+      "integrity": "sha512-7p4Kn/gffhQaavNfyDFg7LS5S/UT1JAjyGd4UqR2+jzoYF02eDkj0Ec3+48TsIa4zghjLY87nQHIh/ecK9qLdw==",
6176
+      "dev": true
6177
+    },
6172
     "circular-json": {
6178
     "circular-json": {
6173
       "version": "0.3.3",
6179
       "version": "0.3.3",
6174
       "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz",
6180
       "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz",

+ 1
- 0
package.json View File

110
     "@babel/runtime": "7.5.5",
110
     "@babel/runtime": "7.5.5",
111
     "babel-eslint": "10.0.1",
111
     "babel-eslint": "10.0.1",
112
     "babel-loader": "8.0.4",
112
     "babel-loader": "8.0.4",
113
+    "circular-dependency-plugin": "5.2.0",
113
     "clean-css": "3.4.25",
114
     "clean-css": "3.4.25",
114
     "css-loader": "0.28.7",
115
     "css-loader": "0.28.7",
115
     "eslint": "5.6.1",
116
     "eslint": "5.6.1",

+ 8
- 0
webpack.config.js View File

1
 /* global __dirname */
1
 /* global __dirname */
2
 
2
 
3
+const CircularDependencyPlugin = require('circular-dependency-plugin');
3
 const process = require('process');
4
 const process = require('process');
4
 const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
5
 const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
5
 
6
 
11
     = process.env.WEBPACK_DEV_SERVER_PROXY_TARGET || 'https://alpha.jitsi.net';
12
     = process.env.WEBPACK_DEV_SERVER_PROXY_TARGET || 'https://alpha.jitsi.net';
12
 
13
 
13
 const analyzeBundle = process.argv.indexOf('--analyze-bundle') !== -1;
14
 const analyzeBundle = process.argv.indexOf('--analyze-bundle') !== -1;
15
+const detectCircularDeps = process.argv.indexOf('--detect-circular-deps') !== -1;
14
 
16
 
15
 const minimize
17
 const minimize
16
     = process.argv.indexOf('-p') !== -1
18
     = process.argv.indexOf('-p') !== -1
155
             && new BundleAnalyzerPlugin({
157
             && new BundleAnalyzerPlugin({
156
                 analyzerMode: 'disabled',
158
                 analyzerMode: 'disabled',
157
                 generateStatsFile: true
159
                 generateStatsFile: true
160
+            }),
161
+        detectCircularDeps
162
+            && new CircularDependencyPlugin({
163
+                allowAsyncCycles: false,
164
+                exclude: /node_modules/,
165
+                failOnError: false
158
             })
166
             })
159
     ].filter(Boolean),
167
     ].filter(Boolean),
160
     resolve: {
168
     resolve: {

Loading…
Cancel
Save