-
-
Notifications
You must be signed in to change notification settings - Fork 6.1k
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
feat: support Rollup logging functions #13757
base: main
Are you sure you want to change the base?
Conversation
Run & review this pull request in StackBlitz Codeflow. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the PR!
The support for this.info
/this.debug
is needed too.
https://github.com/vitejs/vite/pull/13608/files#diff-c0b6eb176448702b6325d2e1b2567c5ccf969f03eef1242950e0bfb18877022fR192-R196
https://github.com/vitejs/vite/pull/13608/files#diff-c0b6eb176448702b6325d2e1b2567c5ccf969f03eef1242950e0bfb18877022fR412-R413
packages/vite/src/node/build.ts
Outdated
config.logger.info( | ||
`${colors.bold( | ||
colors.gray(`[plugin:${logging.plugin}]`), | ||
)} ${colors.gray(logging.message)}`, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use debug
function for debug logs in other places. Let's use it here as well.
https://github.com/vitejs/vite/blob/1292ad08a06e2ae8c44307797ba533f64a602759/packages/vite/src/node/utils.ts#L157C17-L157C31
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sapphi-red
Thank you for your review.
I missed vite's debugger implementation. I pushed the commit fixing it to use Vite's debugger.
Please check it.
onwarn(warning, warn) { | ||
onRollupWarning(warning, warn, config) | ||
onLog(level, log, defaultHandler) { | ||
onRollupLog(level, log, defaultHandler, config) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you check if onwarn
is called before onLog
or not? If onLog
is called before onwarn
, I think we'll need to pass both onwarn
and onLog
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sapphi-red
Thank you for your review!
When rollup calls the logger with warn, onwarn
is called after onLog
. And my understanding is that onwarn
is only called when the default handler is called at onLog
.
In the event of a warning, only logs that are not handled by the handling implemented in onRollupLog
(ignoring specific warning logs or handling plugin logs) will be passed to the default handler and onwarn
will be called. On that premise, passing the same implementation to onLog
and onwarn
does not make sense because the same handling (which is also executed in onlog) is executed.
What do you think about this?
Description
This PR contains feature of supporting Rollup logging function.
Originally, the Vite used onWarn to handle only warnings, but this pull request uses onLog to add handling for info, debug, and error log levels.
Additional context
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).