Currently the `ts-circular-deps` tool uses a hard-coded module resolver that only works in the `angular/angular` repository. If the tool is consumed in other repositories through the shared dev-infra package, the module resolution won't work, and a few resolvable imports (usually cross-entry-points) are accidentally skipped. For each test, the resolution might differ, so tests can now configure their module resolution in a configuration file. Note that we intentionally don't rely on tsconfig's for module resolution as parsing their mappings rather complicates the circular dependency tool. Additionally, not every test has a corresponding tsconfig file. Also, hard-coding mappings to `@angular/*` while accepting a path to the packages folder would work, but it would mean that the circular deps tool is no longer self-contained. Rather, and also for better flexibility, a custom resolver should be specified. PR Close #36226
		
			
				
	
	
		
			32 lines
		
	
	
		
			1020 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			32 lines
		
	
	
		
			1020 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
/**
 | 
						|
 * @license
 | 
						|
 * Copyright Google Inc. All Rights Reserved.
 | 
						|
 *
 | 
						|
 * Use of this source code is governed by an MIT-style license that can be
 | 
						|
 * found in the LICENSE file at https://angular.io/license
 | 
						|
 */
 | 
						|
 | 
						|
const path = require('path');
 | 
						|
 | 
						|
module.exports = {
 | 
						|
  baseDir: '../',
 | 
						|
  goldenFile: '../goldens/packages-circular-deps.json',
 | 
						|
  // The test should not capture deprecated packages such as `http`, or the `webworker` platform.
 | 
						|
  glob: `./!(http|platform-webworker|platform-webworker-dynamic)/**/*.ts`,
 | 
						|
  // Command that will be displayed if the golden needs to be updated.
 | 
						|
  approveCommand: 'yarn ts-circular-deps:approve',
 | 
						|
  resolveModule: resolveModule
 | 
						|
};
 | 
						|
 | 
						|
/**
 | 
						|
 * Custom module resolver that maps specifiers starting with `@angular/` to the
 | 
						|
 * local packages folder. This ensures that cross package/entry-point dependencies
 | 
						|
 * can be detected.
 | 
						|
 */
 | 
						|
function resolveModule(specifier) {
 | 
						|
  if (specifier.startsWith('@angular/')) {
 | 
						|
    return path.join(__dirname, specifier.substr('@angular/'.length));
 | 
						|
  }
 | 
						|
  return null;
 | 
						|
}
 |