Skip to content

Commit 607a1fd

Browse files
committed
build: Check for circular dep with madge
Madge (https://www.npmjs.com/package/madge) is a library that can traverse module dependency trees to check for circular dependencies. We can leverage it using `madge --circular /path/to/index.ts` to make sure that our packages don't contain circular deps. On average madge takes around 2-3 sec, so we are not sacrificing a ton of CI time.
1 parent 17b12e1 commit 607a1fd

File tree

20 files changed

+469
-42
lines changed

20 files changed

+469
-42
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"codecov": "codecov",
1515
"pack:changed": "lerna run pack --since",
1616
"prepublishOnly": "lerna run --stream --concurrency 1 prepublishOnly",
17-
"postpublish": "make publish-docs && lerna run --stream --concurrency 1 postpublish"
17+
"postpublish": "make publish-docs && lerna run --stream --concurrency 1 postpublish",
18+
"circularDepCheck": "lerna run --parallel circularDepCheck"
1819
},
1920
"volta": {
2021
"node": "14.17.0",

packages/angular/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
"npm-run-all": "^4.1.2",
3737
"prettier": "1.19.0",
3838
"rimraf": "^2.6.3",
39-
"typescript": "3.7.5"
39+
"typescript": "3.7.5",
40+
"madge": "4.0.2"
4041
},
4142
"scripts": {
4243
"build": "run-p build:es5 build:esm",
@@ -53,7 +54,8 @@
5354
"fix": "run-s fix:eslint fix:prettier",
5455
"fix:prettier": "prettier --write \"{src,test}/**/*.ts\"",
5556
"fix:eslint": "eslint . --format stylish --fix",
56-
"pack": "npm pack"
57+
"pack": "npm pack",
58+
"circularDepCheck": "madge --circular src/index.ts"
5759
},
5860
"volta": {
5961
"extends": "../../package.json"

packages/browser/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@
5252
"rollup-plugin-typescript2": "^0.21.0",
5353
"sinon": "^7.3.2",
5454
"typescript": "3.7.5",
55-
"webpack": "^4.30.0"
55+
"webpack": "^4.30.0",
56+
"madge": "4.0.2"
5657
},
5758
"scripts": {
5859
"build": "run-s build:dist build:esm build:bundle",
@@ -83,7 +84,8 @@
8384
"size:check": "run-p size:check:es5 size:check:es6",
8485
"size:check:es5": "cat build/bundle.min.js | gzip -9 | wc -c | awk '{$1=$1/1024; print \"ES5: \",$1,\"kB\";}'",
8586
"size:check:es6": "cat build/bundle.es6.min.js | gzip -9 | wc -c | awk '{$1=$1/1024; print \"ES6: \",$1,\"kB\";}'",
86-
"pack": "npm pack"
87+
"pack": "npm pack",
88+
"circularDepCheck": "madge --circular src/index.ts"
8789
},
8890
"volta": {
8991
"extends": "../../package.json"

packages/core/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
"npm-run-all": "^4.1.2",
3030
"prettier": "1.19.0",
3131
"rimraf": "^2.6.3",
32-
"typescript": "3.7.5"
32+
"typescript": "3.7.5",
33+
"madge": "4.0.2"
3334
},
3435
"scripts": {
3536
"build": "run-p build:es5 build:esm",
@@ -49,7 +50,8 @@
4950
"test": "jest",
5051
"test:watch": "jest --watch",
5152
"pack": "npm pack",
52-
"version": "node ../../scripts/versionbump.js src/version.ts"
53+
"version": "node ../../scripts/versionbump.js src/version.ts",
54+
"circularDepCheck": "madge --circular src/index.ts"
5355
},
5456
"volta": {
5557
"extends": "../../package.json"

packages/eslint-config-sdk/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,15 @@
3434
},
3535
"devDependencies": {
3636
"eslint": "7.6.0",
37-
"typescript": "3.7.5"
37+
"typescript": "3.7.5",
38+
"madge": "4.0.2"
3839
},
3940
"scripts": {
4041
"link:yarn": "yarn link",
4142
"lint": "prettier --check \"**/*.js\"",
4243
"fix": "prettier --write \"**/*.js\"",
43-
"pack": "npm pack"
44+
"pack": "npm pack",
45+
"circularDepCheck": "madge --circular src/index.js"
4446
},
4547
"volta": {
4648
"extends": "../../package.json"

packages/eslint-plugin-sdk/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,16 @@
2424
"devDependencies": {
2525
"mocha": "^6.2.0",
2626
"prettier": "1.19.0",
27-
"typescript": "3.7.5"
27+
"typescript": "3.7.5",
28+
"madge": "4.0.2"
2829
},
2930
"scripts": {
3031
"link:yarn": "yarn link",
3132
"lint": "prettier --check \"{src,test}/**/*.js\"",
3233
"fix": "prettier --write \"{src,test}/**/*.js\"",
3334
"test": "mocha test --recursive",
34-
"pack": "npm pack"
35+
"pack": "npm pack",
36+
"circularDepCheck": "madge --circular src/index.js"
3537
},
3638
"volta": {
3739
"extends": "../../package.json"

packages/gatsby/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@
4141
"prettier": "1.19.0",
4242
"react": "^17.0.0",
4343
"rimraf": "^2.6.3",
44-
"typescript": "3.7.5"
44+
"typescript": "3.7.5",
45+
"madge": "4.0.2"
4546
},
4647
"scripts": {
4748
"build": "run-p build:es5 build:esm",
@@ -60,7 +61,8 @@
6061
"fix:eslint": "eslint . --format stylish --fix",
6162
"test": "jest",
6263
"test:watch": "jest --watch",
63-
"pack": "npm pack"
64+
"pack": "npm pack",
65+
"circularDepCheck": "madge --circular src/index.ts"
6466
},
6567
"volta": {
6668
"extends": "../../package.json"

packages/hub/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
"npm-run-all": "^4.1.2",
2828
"prettier": "1.19.0",
2929
"rimraf": "^2.6.3",
30-
"typescript": "3.7.5"
30+
"typescript": "3.7.5",
31+
"madge": "4.0.2"
3132
},
3233
"scripts": {
3334
"build": "run-p build:es5 build:esm",
@@ -46,7 +47,8 @@
4647
"fix:eslint": "eslint . --format stylish --fix",
4748
"test": "jest",
4849
"test:watch": "jest --watch",
49-
"pack": "npm pack"
50+
"pack": "npm pack",
51+
"circularDepCheck": "madge --circular src/index.ts"
5052
},
5153
"volta": {
5254
"extends": "../../package.json"

packages/integrations/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
"rollup-plugin-node-resolve": "^4.2.3",
3535
"rollup-plugin-terser": "^4.0.4",
3636
"rollup-plugin-typescript2": "^0.21.0",
37-
"typescript": "3.7.5"
37+
"typescript": "3.7.5",
38+
"madge": "4.0.2"
3839
},
3940
"scripts": {
4041
"build": "run-p build:es5 build:esm build:bundle",
@@ -54,7 +55,8 @@
5455
"fix:eslint": "eslint . --format stylish --fix",
5556
"test": "jest",
5657
"test:watch": "jest --watch",
57-
"pack": "npm pack"
58+
"pack": "npm pack",
59+
"circularDepCheck": "madge --circular src/index.ts"
5860
},
5961
"volta": {
6062
"extends": "../../package.json"

packages/minimal/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
"npm-run-all": "^4.1.2",
2828
"prettier": "1.19.0",
2929
"rimraf": "^2.6.3",
30-
"typescript": "3.7.5"
30+
"typescript": "3.7.5",
31+
"madge": "4.0.2"
3132
},
3233
"scripts": {
3334
"build": "run-p build:es5 build:esm",
@@ -46,7 +47,8 @@
4647
"fix:eslint": "eslint . --format stylish --fix",
4748
"test": "jest",
4849
"test:watch": "jest --watch",
49-
"pack": "npm pack"
50+
"pack": "npm pack",
51+
"circularDepCheck": "madge --circular src/index.ts"
5052
},
5153
"volta": {
5254
"extends": "../../package.json"

packages/nextjs/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
"@types/webpack": "^5.28.0",
3232
"eslint": "7.20.0",
3333
"next": "10.1.3",
34-
"rimraf": "3.0.2"
34+
"rimraf": "3.0.2",
35+
"madge": "4.0.2"
3536
},
3637
"peerDependencies": {
3738
"next": "^10.0.8",
@@ -61,7 +62,8 @@
6162
"test:integration:client": "node test/integration/test/client.js --silent",
6263
"pack": "npm pack",
6364
"vercel:branch": "source vercel/set-up-branch-for-test-app-use.sh",
64-
"vercel:project": "source vercel/make-project-use-current-branch.sh"
65+
"vercel:project": "source vercel/make-project-use-current-branch.sh",
66+
"circularDepCheck": "madge --circular src/index.client.ts && madge --circular src/index.server.ts"
6567
},
6668
"volta": {
6769
"extends": "../../package.json"

packages/node/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939
"npm-run-all": "^4.1.2",
4040
"prettier": "1.19.0",
4141
"rimraf": "^2.6.3",
42-
"typescript": "3.7.5"
42+
"typescript": "3.7.5",
43+
"madge": "4.0.2"
4344
},
4445
"scripts": {
4546
"build": "run-p build:es5 build:esm",
@@ -62,7 +63,8 @@
6263
"test:express": "node test/manual/express-scope-separation/start.js",
6364
"test:webpack": "cd test/manual/webpack-domain/ && yarn && node npm-build.js",
6465
"test:release-health": "node test/manual/release-health/single-session/healthy-session.js && node test/manual/release-health/single-session/caught-exception-errored-session.js && node test/manual/release-health/single-session/uncaught-exception-crashed-session.js && node test/manual/release-health/single-session/unhandled-rejection-crashed-session.js && node test/manual/release-health/session-aggregates/aggregates-disable-single-session.js",
65-
"pack": "npm pack"
66+
"pack": "npm pack",
67+
"circularDepCheck": "madge --circular src/index.ts"
6668
},
6769
"volta": {
6870
"extends": "../../package.json"

packages/react/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@
5454
"react-test-renderer": "^16.13.1",
5555
"redux": "^4.0.5",
5656
"rimraf": "^2.6.3",
57-
"typescript": "3.7.5"
57+
"typescript": "3.7.5",
58+
"madge": "4.0.2"
5859
},
5960
"scripts": {
6061
"build": "run-p build:es5 build:esm",
@@ -73,7 +74,8 @@
7374
"fix:eslint": "eslint . --format stylish --fix",
7475
"test": "jest",
7576
"test:watch": "jest --watch",
76-
"pack": "npm pack"
77+
"pack": "npm pack",
78+
"circularDepCheck": "madge --circular src/index.ts"
7779
},
7880
"volta": {
7981
"extends": "../../package.json"

packages/serverless/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@
4343
"prettier": "1.19.0",
4444
"read-pkg": "^5.2.0",
4545
"rimraf": "^2.6.3",
46-
"typescript": "3.7.5"
46+
"typescript": "3.7.5",
47+
"madge": "4.0.2"
4748
},
4849
"scripts": {
4950
"build": "run-s build:es build:awslambda-layer",
@@ -64,7 +65,8 @@
6465
"fix:eslint": "eslint . --format stylish --fix",
6566
"test": "jest",
6667
"test:watch": "jest --watch",
67-
"pack": "npm pack"
68+
"pack": "npm pack",
69+
"circularDepCheck": "madge --circular src/index.ts"
6870
},
6971
"volta": {
7072
"extends": "../../package.json"

packages/tracing/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939
"rollup-plugin-node-resolve": "^4.2.3",
4040
"rollup-plugin-terser": "^4.0.4",
4141
"rollup-plugin-typescript2": "^0.21.0",
42-
"typescript": "3.7.5"
42+
"typescript": "3.7.5",
43+
"madge": "4.0.2"
4344
},
4445
"scripts": {
4546
"build": "run-p build:es5 build:esm build:bundle",
@@ -60,7 +61,8 @@
6061
"fix:eslint": "eslint . --format stylish --fix",
6162
"test": "jest",
6263
"test:watch": "jest --watch",
63-
"pack": "npm pack"
64+
"pack": "npm pack",
65+
"circularDepCheck": "madge --circular src/index.ts"
6466
},
6567
"volta": {
6668
"extends": "../../package.json"

packages/types/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
"eslint": "7.6.0",
2121
"npm-run-all": "^4.1.2",
2222
"prettier": "1.19.0",
23-
"typescript": "3.7.5"
23+
"typescript": "3.7.5",
24+
"madge": "4.0.2"
2425
},
2526
"scripts": {
2627
"build": "run-p build:es5 build:esm",
@@ -36,7 +37,8 @@
3637
"fix": "run-s fix:eslint fix:prettier",
3738
"fix:prettier": "prettier --write \"{src,test}/**/*.ts\"",
3839
"fix:eslint": "eslint . --format stylish --fix",
39-
"pack": "npm pack"
40+
"pack": "npm pack",
41+
"circularDepCheck": "madge --circular src/index.ts"
4042
},
4143
"volta": {
4244
"extends": "../../package.json"

packages/utils/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
"npm-run-all": "^4.1.2",
2828
"prettier": "1.19.0",
2929
"rimraf": "^2.6.3",
30-
"typescript": "3.7.5"
30+
"typescript": "3.7.5",
31+
"madge": "4.0.2"
3132
},
3233
"scripts": {
3334
"build": "run-p build:es5 build:esm",
@@ -46,7 +47,8 @@
4647
"fix:eslint": "eslint . --format stylish --fix",
4748
"test": "jest",
4849
"test:watch": "jest --watch",
49-
"pack": "npm pack"
50+
"pack": "npm pack",
51+
"circularDepCheck": "madge --circular src/index.ts"
5052
},
5153
"volta": {
5254
"extends": "../../package.json"

packages/vue/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@
4343
"rollup-plugin-typescript2": "^0.21.0",
4444
"typescript": "3.7.5",
4545
"vue": "^2.6",
46-
"vue-router": "^3.0.1"
46+
"vue-router": "^3.0.1",
47+
"madge": "4.0.2"
4748
},
4849
"scripts": {
4950
"build": "run-p build:es5 build:esm build:bundle",
@@ -64,7 +65,8 @@
6465
"fix:eslint": "eslint . --format stylish --fix",
6566
"test": "jest --passWithNoTests",
6667
"test:watch": "jest --watch",
67-
"pack": "npm pack"
68+
"pack": "npm pack",
69+
"circularDepCheck": "madge --circular src/index.ts"
6870
},
6971
"volta": {
7072
"extends": "../../package.json"

packages/wasm/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@
3737
"rollup-plugin-node-resolve": "^4.2.3",
3838
"rollup-plugin-terser": "^4.0.4",
3939
"rollup-plugin-typescript2": "^0.21.0",
40-
"typescript": "3.7.5"
40+
"typescript": "3.7.5",
41+
"madge": "4.0.2"
4142
},
4243
"scripts": {
4344
"build": "run-p build:es5 build:esm build:bundle",
@@ -57,7 +58,8 @@
5758
"fix:eslint": "eslint . --format stylish --fix",
5859
"test": "PORT=1337 jest",
5960
"test:watch": "jest --watch",
60-
"pack": "npm pack"
61+
"pack": "npm pack",
62+
"circularDepCheck": "madge --circular src/index.ts"
6163
},
6264
"volta": {
6365
"extends": "../../package.json"

0 commit comments

Comments
 (0)