Browse Source

added circular reference detection on webpack build

bach 2 years ago
parent
commit
2ebf074816
3 changed files with 23 additions and 0 deletions
  1. 16 0
      build/webpack.config.base.js
  2. 6 0
      package-lock.json
  3. 1 0
      package.json

+ 16 - 0
build/webpack.config.base.js

@@ -5,6 +5,7 @@ const ESLintPlugin = require('eslint-webpack-plugin');
 const ExtraneousFileCleanupPlugin = require('webpack-extraneous-file-cleanup-plugin');
 const CompressionPlugin = require("compression-webpack-plugin");
 const { CleanWebpackPlugin } = require('clean-webpack-plugin');
+const CircularDependencyPlugin = require('circular-dependency-plugin')
 
 const utils = require('./utils')
 
@@ -13,6 +14,8 @@ const langPath = 'web/sites/default/files/lang'
 
 const isDev = process.env.NODE_ENV === 'development';
 
+
+
 module.exports = {
   resolve: {
     extensions: ['.js', '.vue', '.json'],
@@ -172,5 +175,18 @@ module.exports = {
      * See `Options and Defaults` for information
      */
      new CleanWebpackPlugin(),
+     new CircularDependencyPlugin({
+      // exclude detection of files based on a RegExp
+      exclude: /a\.js|node_modules/,
+      // include specific files based on a RegExp
+      // include: /dir/,
+      // add errors to webpack instead of warnings
+      failOnError: false,
+      // allow import cycles that include an asyncronous import,
+      // e.g. via import(/* webpackMode: "weak" */ './file.js')
+      allowAsyncCycles: false,
+      // set the current working directory for displaying module paths
+      // cwd: process.cwd(),
+    })
   ]
 }

+ 6 - 0
package-lock.json

@@ -3023,6 +3023,12 @@
       "integrity": "sha512-vsGdkwSCDpWmP80ncATX7iea5DWQemg1UgCW5J8tqjU3lYw4FBYuj89J0CTVomA7BEfvSZd84GmHko+MxFQU2A==",
       "dev": true
     },
+    "circular-dependency-plugin": {
+      "version": "5.2.2",
+      "resolved": "https://registry.npmjs.org/circular-dependency-plugin/-/circular-dependency-plugin-5.2.2.tgz",
+      "integrity": "sha512-g38K9Cm5WRwlaH6g03B9OEz/0qRizI+2I7n+Gz+L5DxXJAPAiWQvwlYNm1V1jkdpUv95bOe/ASm2vfi/G560jQ==",
+      "dev": true
+    },
     "class-utils": {
       "version": "0.3.6",
       "resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz",

+ 1 - 0
package.json

@@ -42,6 +42,7 @@
     "babel-eslint": "^10.1.0",
     "babel-jest": "^26.6.3",
     "babel-loader": "^8.2.1",
+    "circular-dependency-plugin": "^5.2.2",
     "clean-webpack-plugin": "^4.0.0-alpha.0",
     "compression-webpack-plugin": "^8.0.0",
     "copy-webpack-plugin": "^6.3.2",