From 2ebf0748161fb68465dceeaadd0ce6333b955028 Mon Sep 17 00:00:00 2001 From: bach Date: Tue, 8 Mar 2022 14:25:53 +0100 Subject: [PATCH] added circular reference detection on webpack build --- build/webpack.config.base.js | 16 ++++++++++++++++ package-lock.json | 6 ++++++ package.json | 1 + 3 files changed, 23 insertions(+) diff --git a/build/webpack.config.base.js b/build/webpack.config.base.js index f6da3843..1901fb5d 100644 --- a/build/webpack.config.base.js +++ b/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(), + }) ] } diff --git a/package-lock.json b/package-lock.json index 87fb2ebc..eb8bb776 100644 --- a/package-lock.json +++ b/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", diff --git a/package.json b/package.json index 6bf8a362..465d5520 100644 --- a/package.json +++ b/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",