From b65860fee2e842c31cf6e52122561a962617eec0 Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Mon, 17 Sep 2018 14:54:42 +0200 Subject: [PATCH] feat(@ngtools/webpack): add support for `traceResolution` Closes #8676 --- packages/ngtools/webpack/src/compiler_host.ts | 4 ++++ .../e2e/tests/misc/trace-resolution.ts | 22 +++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 tests/legacy-cli/e2e/tests/misc/trace-resolution.ts diff --git a/packages/ngtools/webpack/src/compiler_host.ts b/packages/ngtools/webpack/src/compiler_host.ts index a5c2572dfdce..2c0ea9b65c93 100644 --- a/packages/ngtools/webpack/src/compiler_host.ts +++ b/packages/ngtools/webpack/src/compiler_host.ts @@ -246,6 +246,10 @@ export class WebpackCompilerHost implements ts.CompilerHost { return this.readFile(fileName); } } + + trace(message: string) { + console.log(message); + } } diff --git a/tests/legacy-cli/e2e/tests/misc/trace-resolution.ts b/tests/legacy-cli/e2e/tests/misc/trace-resolution.ts new file mode 100644 index 000000000000..30c8113ce9ec --- /dev/null +++ b/tests/legacy-cli/e2e/tests/misc/trace-resolution.ts @@ -0,0 +1,22 @@ +import { ng } from '../../utils/process'; +import { updateJsonFile } from '../../utils/project'; + +export default async function () { + await updateJsonFile('tsconfig.json', tsconfig => { + tsconfig.compilerOptions.traceResolution = true; + }); + + const { stdout: stdoutTraced } = await ng('build'); + if (!/Resolving module/.test(stdoutTraced)) { + throw new Error(`Modules resolutions must be printed when 'traceResolution' is enabled.`); + } + + await updateJsonFile('tsconfig.json', tsconfig => { + tsconfig.compilerOptions.traceResolution = false; + }); + + const { stdout: stdoutUnTraced } = await ng('build'); + if (/Resolving module/.test(stdoutUnTraced)) { + throw new Error(`Modules resolutions must not be printed when 'traceResolution' is disabled.`); + } +}