diff --git a/BUILD b/BUILD index 6bc4c007c4..f6be0be0aa 100644 --- a/BUILD +++ b/BUILD @@ -853,3 +853,29 @@ public_api_test( public_api = ":public_api", size = "small", ) + +nodejs_test( + name = "check_cycle_test", + srcs = [ + "//build_defs:check_cycle.js", + ], + deps = [ + ":madge", + ], + entry_point = "check_cycle.js", + data = [ + ":core", + ":common", + ":compiler", + ":compiler-cli", + ":forms", + ":http", + ":platform-browser", + ":platform-browser-dynamic", + ":platform-server", + ":router", + ":upgrade", + ":tsc-wrapped", + ], + size = "small", +) diff --git a/build_defs/BUILD b/build_defs/BUILD index e357eb7bc1..ddad628cef 100644 --- a/build_defs/BUILD +++ b/build_defs/BUILD @@ -5,4 +5,5 @@ exports_files([ "rollup_config_template.js", "protractor_launcher_template.sh", "ts_api_guardian_launcher_template.sh", + "check_cycle.js", ]) diff --git a/build_defs/check_cycle.js b/build_defs/check_cycle.js new file mode 100644 index 0000000000..57f2cf9d07 --- /dev/null +++ b/build_defs/check_cycle.js @@ -0,0 +1,16 @@ +'use strict'; + +const madge = require('madge'); + +const dependencyObject = madge([process.env.RUNFILES + '/modules/'], { + format: 'cjs', + extensions: ['.js'], + onParseFile: function(data) { data.src = data.src.replace(/\/\* circular \*\//g, '//'); } +}); + +const circularDependencies = dependencyObject.circular().getArray(); +if (circularDependencies.length > 0) { + console.log('Found circular dependencies!'); + console.log(circularDependencies); + process.exit(1); +}