Skip to content
This repository was archived by the owner on May 1, 2020. It is now read-only.

Commit efc4039

Browse files
committed
feature(dependencies): flag to print out dependency tree
1 parent 1128c9c commit efc4039

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

src/logger/logger.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,10 @@ export class Logger {
168168
console.error(chalk.red(msg));
169169
}
170170

171+
static unformattedDebug(msg: string) {
172+
console.log(chalk.cyan(msg));
173+
}
174+
171175
/**
172176
* Prints out a blue colored DEBUG prefix. Only prints out when debug mode.
173177
*/

src/optimization.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,10 @@ export function processStatsImpl(webpackStats: WebpackStats) {
9090
});
9191
}
9292

93-
// printDependencyMap(dependencyMap);
93+
if (getBooleanPropertyValue(Constants.ENV_PRINT_DEPENDENCY_TREE)) {
94+
printDependencyMap(dependencyMap);
95+
}
96+
9497
return dependencyMap;
9598
}
9699

@@ -100,10 +103,10 @@ export function purgeWebpackPrefixFromPath(filePath: string) {
100103

101104
function printDependencyMap(map: Map<string, Set<string>>) {
102105
map.forEach((dependencySet: Set<string>, filePath: string) => {
103-
console.log('\n\n');
104-
console.log(`${filePath} is imported by the following files:`);
106+
Logger.unformattedDebug('\n\n');
107+
Logger.unformattedDebug(`${filePath} is imported by the following files:`);
105108
dependencySet.forEach((importeePath: string) => {
106-
console.log(` ${importeePath}`);
109+
Logger.unformattedDebug(` ${importeePath}`);
107110
});
108111
});
109112
}

src/util/config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,10 @@ export function generateContext(context?: BuildContext): BuildContext {
131131
const aotWriteToDisk = getConfigValue(context, '--aotWriteToDisk', null, Constants.ENV_AOT_WRITE_TO_DISK, Constants.ENV_AOT_WRITE_TO_DISK.toLowerCase(), null);
132132
setProcessEnvVar(Constants.ENV_AOT_WRITE_TO_DISK, aotWriteToDisk);
133133

134+
const printDependencyTree = getConfigValue(context, '--printDependencyTree', null, Constants.ENV_PRINT_DEPENDENCY_TREE, Constants.ENV_PRINT_DEPENDENCY_TREE.toLowerCase(), null);
135+
setProcessEnvVar(Constants.ENV_PRINT_DEPENDENCY_TREE, printDependencyTree);
136+
137+
134138
const bailOnLintError = getConfigValue(context, '--bailOnLintError', null, Constants.ENV_BAIL_ON_LINT_ERROR, Constants.ENV_BAIL_ON_LINT_ERROR.toLowerCase(), null);
135139
setProcessEnvVar(Constants.ENV_BAIL_ON_LINT_ERROR, bailOnLintError);
136140

src/util/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export const ENV_OPTIMIZATION_LOADER = 'IONIC_OPTIMIZATION_LOADER';
4747
export const ENV_AOT_WRITE_TO_DISK = 'IONIC_AOT_WRITE_TO_DISK';
4848
export const ENV_BAIL_ON_LINT_ERROR = 'IONIC_BAIL_ON_LINT_ERROR';
4949
export const ENV_BUILD_TO_ES5 = 'IONIC_BUILD_TO_ES5';
50+
export const ENV_PRINT_DEPENDENCY_TREE = 'IONIC_PRINT_DEPENDENCY_TREE';
5051

5152
export const ENV_EXPERIMENTAL_PARSE_DEEPLINKS = 'IONIC_EXPERIMENTAL_PARSE_DEEPLINKS';
5253
export const ENV_EXPERIMENTAL_MANUAL_TREESHAKING = 'IONIC_EXPERIMENTAL_MANUAL_TREESHAKING';

0 commit comments

Comments
 (0)