diff --git a/next.config.js b/next.config.js index 091c739d9d..549a7a311a 100644 --- a/next.config.js +++ b/next.config.js @@ -1,6 +1,7 @@ // @ts-check const { BugsnagSourceMapUploaderPlugin } = require("webpack-bugsnag-plugins") +const CircularDependencyPlugin = require("circular-dependency-plugin") /** @type {import("next").NextConfig} */ const nextConfig = { @@ -21,8 +22,8 @@ const nextConfig = { ], }) + if (!config.plugins) config.plugins = [] if (process.env.VERCEL_ENV === "production") { - if (!config.plugins) config.plugins = [] config.plugins.push( new BugsnagSourceMapUploaderPlugin({ apiKey: process.env.NEXT_PUBLIC_BUGSNAG_KEY ?? "", @@ -32,6 +33,16 @@ const nextConfig = { ) } + config.plugins.push( + new CircularDependencyPlugin({ + exclude: /.next|node_modules/, + include: /src/, + // TODO: if all circular dependencies are resolved, set this argument to true + failOnError: false, + allowAsyncCycles: false, + }) + ) + return config }, productionBrowserSourceMaps: true, diff --git a/package-lock.json b/package-lock.json index d13d5fc1e7..766fffa467 100644 --- a/package-lock.json +++ b/package-lock.json @@ -92,6 +92,7 @@ "@types/react-google-recaptcha": "^2.1.5", "@typescript-eslint/eslint-plugin": "^5.54.0", "abitype": "^1.0.2", + "circular-dependency-plugin": "^5.2.2", "cypress": "^13.3.2", "dotenv-cli": "^7.4.1", "eslint": "^8.57.0", @@ -14498,6 +14499,18 @@ "node": ">=8" } }, + "node_modules/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, + "engines": { + "node": ">=6.0.0" + }, + "peerDependencies": { + "webpack": ">=4.0.1" + } + }, "node_modules/citty": { "version": "0.1.6", "resolved": "https://registry.npmjs.org/citty/-/citty-0.1.6.tgz", diff --git a/package.json b/package.json index d3b3a4a070..1fd17545d7 100644 --- a/package.json +++ b/package.json @@ -102,6 +102,7 @@ "@types/react-google-recaptcha": "^2.1.5", "@typescript-eslint/eslint-plugin": "^5.54.0", "abitype": "^1.0.2", + "circular-dependency-plugin": "^5.2.2", "cypress": "^13.3.2", "dotenv-cli": "^7.4.1", "eslint": "^8.57.0",