-
Notifications
You must be signed in to change notification settings - Fork 226
feat: expose logger in plugin API #5462
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
Conversation
✅ Deploy Preview for rsbuild ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
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.
Pull Request Overview
This PR exposes a unified logger
instance on the plugin API, making it easier for plugin authors to log messages consistently.
- Add
logger: Logger
to theRsbuildPluginAPI
type and initialization logic - Update core exports to include the
Logger
type andlogger
instance - Document
api.logger
in both plugin and core API guides, and add an e2e test for the new API
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 6 comments.
Show a summary per file
File | Description |
---|---|
website/docs/zh/plugins/dev/core.mdx | Document api.logger usage in Chinese plugin development guide |
website/docs/zh/api/javascript-api/core.mdx | Clarify logger description in Chinese core API reference |
website/docs/en/plugins/dev/core.mdx | Document api.logger usage in English plugin development guide |
website/docs/en/api/javascript-api/core.mdx | Clarify logger description in English core API reference |
packages/core/src/types/plugin.ts | Add logger: Logger to RsbuildPluginAPI |
packages/core/src/initPlugins.ts | Expose logger on the built plugin API object |
packages/core/src/index.ts | Export Logger type alongside logger |
e2e/cases/plugin-api/logger/src/index.js | Scaffold plugin entry file for e2e test |
e2e/cases/plugin-api/logger/index.test.ts | Add e2e test verifying api.logger |
Comments suppressed due to low confidence (1)
e2e/cases/plugin-api/logger/index.test.ts:5
- [nitpick] The test description mentions "custom resolver" but this case is about the logger API—consider renaming it to something like "should expose logger in plugin API".
test('should allow plugin to custom resolver', async () => {
Summary
While we already export the
logger
from @rsbuild/core, providing theapi.logger
will make it easier and more intuitive for plugin authors (and AI) to use the logger.Checklist