feat: expose logger in plugin API#5462
Merged
chenjiahan merged 2 commits intomainfrom Jun 21, 2025
Merged
Conversation
✅ Deploy Preview for rsbuild ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
There was a problem hiding this comment.
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: Loggerto theRsbuildPluginAPItype and initialization logic - Update core exports to include the
Loggertype andloggerinstance - Document
api.loggerin 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 () => {
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
While we already export the
loggerfrom @rsbuild/core, providing theapi.loggerwill make it easier and more intuitive for plugin authors (and AI) to use the logger.Checklist