added circular reference detection on webpack build

This commit is contained in:
Bachir Soussi Chiadmi 2022-03-08 14:25:53 +01:00
parent c8115f4288
commit 2ebf074816
3 changed files with 23 additions and 0 deletions

View File

@ -5,6 +5,7 @@ const ESLintPlugin = require('eslint-webpack-plugin');
const ExtraneousFileCleanupPlugin = require('webpack-extraneous-file-cleanup-plugin'); const ExtraneousFileCleanupPlugin = require('webpack-extraneous-file-cleanup-plugin');
const CompressionPlugin = require("compression-webpack-plugin"); const CompressionPlugin = require("compression-webpack-plugin");
const { CleanWebpackPlugin } = require('clean-webpack-plugin'); const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const CircularDependencyPlugin = require('circular-dependency-plugin')
const utils = require('./utils') const utils = require('./utils')
@ -13,6 +14,8 @@ const langPath = 'web/sites/default/files/lang'
const isDev = process.env.NODE_ENV === 'development'; const isDev = process.env.NODE_ENV === 'development';
module.exports = { module.exports = {
resolve: { resolve: {
extensions: ['.js', '.vue', '.json'], extensions: ['.js', '.vue', '.json'],
@ -172,5 +175,18 @@ module.exports = {
* See `Options and Defaults` for information * See `Options and Defaults` for information
*/ */
new CleanWebpackPlugin(), 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
package-lock.json generated
View File

@ -3023,6 +3023,12 @@
"integrity": "sha512-vsGdkwSCDpWmP80ncATX7iea5DWQemg1UgCW5J8tqjU3lYw4FBYuj89J0CTVomA7BEfvSZd84GmHko+MxFQU2A==", "integrity": "sha512-vsGdkwSCDpWmP80ncATX7iea5DWQemg1UgCW5J8tqjU3lYw4FBYuj89J0CTVomA7BEfvSZd84GmHko+MxFQU2A==",
"dev": true "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": { "class-utils": {
"version": "0.3.6", "version": "0.3.6",
"resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz", "resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz",

View File

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