Skip to content

feat(@ngtools/webpack): add support for traceResolution #12286

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/ngtools/webpack/src/compiler_host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,10 @@ export class WebpackCompilerHost implements ts.CompilerHost {
return this.readFile(fileName);
}
}

trace(message: string) {
console.log(message);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should use console.log for this, but not sure what else we should use. The webpack compilation only allows for warnings and errors, and they show only at the end of the compilation.

@clydin WDYT?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a side note, I don't think you'd want to display the traceResolutions all at the very end, as this is quite verbose. I think it is quite useful to see that output when a module is being resolved.

}
}


Expand Down
22 changes: 22 additions & 0 deletions tests/legacy-cli/e2e/tests/misc/trace-resolution.ts
Original file line number Diff line number Diff line change
@@ -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.`);
}
}