Skip to content

Conversation

@chenjiahan
Copy link
Member

Summary

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copilot AI review requested due to automatic review settings November 18, 2025 14:50
@netlify
Copy link

netlify bot commented Nov 18, 2025

Deploy Preview for rsbuild ready!

Name Link
🔨 Latest commit 4f3b4fe
🔍 Latest deploy log https://app.netlify.com/projects/rsbuild/deploys/691c879cb2188f0008e548af
😎 Deploy Preview https://deploy-preview-6607--rsbuild.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 57 (🔴 down 1 from production)
Accessibility: 100 (no change from production)
Best Practices: 100 (no change from production)
SEO: 100 (no change from production)
PWA: 60 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@chenjiahan chenjiahan changed the title feat: track build time for each environment feat: improve build time printing Nov 18, 2025
@netlify
Copy link

netlify bot commented Nov 18, 2025

Deploy Preview for rsbuild ready!

Name Link
🔨 Latest commit ca79e0b
🔍 Latest deploy log https://app.netlify.com/projects/rsbuild/deploys/691c8af3fc2b270008628a08
😎 Deploy Preview https://deploy-preview-6607--rsbuild.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 75 (🟢 up 17 from production)
Accessibility: 100 (no change from production)
Best Practices: 100 (no change from production)
SEO: 100 (no change from production)
PWA: 60 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 189 to 207
const printTime = (index: number) => {
if (startTime === null) {
return;
}

const { name } = context.environmentList[index];
const time = Date.now() - startTime;
context.buildState.time[name] = time;

// For multi compiler, print name to distinguish different environments
const suffix = isMultiCompiler ? color.dim(` (${name})`) : '';
logger.ready(`built in ${prettyTime(time / 1000)}${suffix}`);
};

if (isMultiCompiler) {
(compiler as Rspack.MultiCompiler).compilers.forEach((item, index) => {
item.hooks.done.tap(HOOK_NAME, () => {
printTime(index);
});

Choose a reason for hiding this comment

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

P1 Badge Avoid logging build time when the environment fails

The new printTime helper is invoked from both multi-compiler child hooks and the top-level done hook without checking whether the corresponding compiler finished with errors. Previously, timing information was printed only when hasErrors was false. With this change the CLI will emit logger.ready('built in …') messages even when a compilation fails, which presents the build as successful and stores a duration in context.buildState.time for environments that actually errored. This makes error runs harder to diagnose and exposes misleading telemetry. Consider checking stats.hasErrors() (available in the child done hook and from statsInstance in the single-compiler path) before logging or storing the time.

Useful? React with 👍 / 👎.

Copy link
Member Author

Choose a reason for hiding this comment

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

I will improve the time logs when having build errors.

Copilot finished reviewing on behalf of chenjiahan November 18, 2025 14:54
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements per-environment build time tracking by storing timing data in the internal context object and outputting build times immediately after each environment completes, rather than waiting for all environments to finish building.

Key Changes:

  • Adds time: Record<string, number> field to BuildState to track build duration for each environment
  • Replaces stats-based timing with direct Date.now() measurement for more accurate control
  • Outputs build times immediately when each environment's compilation completes in multi-compiler scenarios

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/core/src/types/context.ts Adds time field to BuildState type to store per-environment build durations
packages/core/src/types/rsbuild.ts Removes time from RsbuildStatsItem as timing is now tracked separately
packages/core/src/createContext.ts Initializes the time object as an empty record in build state
packages/core/src/provider/createCompiler.ts Implements timing logic using Date.now() and prints times immediately per environment
packages/core/src/helpers/stats.ts Removes timings: true from stats options as time is now tracked independently

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@chenjiahan chenjiahan merged commit b37faa8 into main Nov 19, 2025
11 checks passed
@chenjiahan chenjiahan deleted the build_time_1118 branch November 19, 2025 01:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants