Skip to content

Commit

Permalink
feat: add rebuild info to stats
Browse files Browse the repository at this point in the history
  • Loading branch information
rafalmaciejewski committed Apr 26, 2020
1 parent 903a3cf commit 9fcb0bf
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"@semantic-release/github": "^7.0.5",
"@semantic-release/npm": "^7.0.5",
"@semantic-release/release-notes-generator": "^9.0.1",
"@types/node": "^13.13.2",
"@types/node": "^13.13.4",
"@types/webpack": "^4.41.12",
"@typescript-eslint/eslint-plugin": "^2.29.0",
"cz-conventional-changelog": "^3.1.0",
Expand Down
3 changes: 2 additions & 1 deletion src/BuildTimeReport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class BuildTimeReport {
private hash?: string;
private initialResource?: string;

constructor(private readonly projectRoot: string) {}
constructor(private readonly projectRoot: string, private readonly rebuild: boolean = false) {}

public track(step: Step): void {
const stepStats = this.steps.get(step);
Expand Down Expand Up @@ -71,6 +71,7 @@ export class BuildTimeReport {
assetCount: this.assets.length,
modulesCount: this.modules.length,
initialResource: this.initialResource,
rebuild: this.rebuild,
};
}

Expand Down
5 changes: 4 additions & 1 deletion src/BuildTimeReporterWebpackPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ const schema: JSONSchema4 = {
additionalProperties: false,
};

let rebuild = false;

export class BuildTimeReporterWebpackPlugin {
private reportsByHash: Map<string, BuildTimeReport> = new Map();
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down Expand Up @@ -102,7 +104,8 @@ export class BuildTimeReporterWebpackPlugin {

private createReportAndTrackCompilation(): void {
tapInto(this.compiler, 'compilation', (compilation) => {
const report = new BuildTimeReport(this.compiler.context);
const report = new BuildTimeReport(this.compiler.context, rebuild);
rebuild = true;
report.start();
this.setReportHash(compilation, report);
this.trackBuild(compilation, report);
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ export interface BuildTimeReporterStats {
duration: number;
steps: Record<Step, StepStats>;
initialResource?: string;
rebuild: boolean;
}

0 comments on commit 9fcb0bf

Please sign in to comment.