Sfoglia il codice sorgente

dev: add plugin for circular dependency detection

Example run: https://gist.github.com/saghul/e5e12edc108bdedbcbe65a3d7528235f
master
Saúl Ibarra Corretgé 4 anni fa
parent
commit
d4d1d0aa70
3 ha cambiato i file con 15 aggiunte e 0 eliminazioni
  1. 6
    0
      package-lock.json
  2. 1
    0
      package.json
  3. 8
    0
      webpack.config.js

+ 6
- 0
package-lock.json Vedi File

@@ -6169,6 +6169,12 @@
6169 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 6178
     "circular-json": {
6173 6179
       "version": "0.3.3",
6174 6180
       "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz",

+ 1
- 0
package.json Vedi File

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

+ 8
- 0
webpack.config.js Vedi File

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

Loading…
Annulla
Salva