Skip to content

Conversation

@fi3ework
Copy link
Member

Summary

Previously, Rslib's logs have continuously accumulated results from previous builds, which can make it challenging to observe the outcomes of the most recent builds, particularly when there were errors in earlier builds.

In this PR, soft clear on watch mode.

Before:

before.mp4

After:

after.mp4

Related Links

Checklist

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

import { loadTsconfig } from './utils/tsconfig';

rsbuildLogger.override({
start: (message) => {
Copy link
Member

@chenjiahan chenjiahan Jan 14, 2025

Choose a reason for hiding this comment

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

Overriding logger.start is not a good idea, how about using a hook like onBeforeBuild

Copy link
Member

Choose a reason for hiding this comment

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

We cannot guarantee that logger.start will not be called from somewhere else

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 tried onBeforeBuild before, but when multiple environments presents. It will be called multiple times. I think I should re-implement something like Building... with Rspack watchRun and done hook in Rslib side.

Copy link
Contributor

Choose a reason for hiding this comment

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

onBeforeBuild is a global hook, are you registering plugins in global?

Copy link
Member Author

@fi3ework fi3ework Jan 14, 2025

Choose a reason for hiding this comment

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

onBeforeBuild is a global hook, are you registering plugins in global?

Yes. 🤡

Copy link
Member Author

Choose a reason for hiding this comment

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

@chenjiahan 🤔 Does Rsbuild interest in embed this clear so Rslib can inherit? The usage are same. It's better to align with Rsbuild.

Copy link
Member

Choose a reason for hiding this comment

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

Rsbuild will not clear the logs before rebuilding, as this will likely cause useful logs to be cleared and make troubleshooting more difficult.

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'd like to give a try on Rslib, hoping it fit with the simpler lib scenario. 😀

Copy link
Member

Choose a reason for hiding this comment

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

In fact, Rsbuild early versions will clear the log by default, but we later found that this caused more trouble than benefit, so we canceled it. However, for Rslib scenarios it is still worth a try.

Copy link
Member Author

Choose a reason for hiding this comment

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

Can't find an elegant way to archive this, I'm heading to close for now.

  • onBeforeBuild will run after Building... and clear it, so it's not an option.
  • watchRun is good, but can't find a way to register the plugin for only once. Register to the first environment only is also an ugly workaround.

@Timeless0911 Timeless0911 changed the title fix: clear console before ready log feat: clear console before ready log Jan 14, 2025
@fi3ework fi3ework closed this Jan 14, 2025
@Timeless0911 Timeless0911 deleted the ready-log branch July 16, 2025 07:50
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.

4 participants