Skip to content

fix: avoid import { logger } from '@rsbuild/core'#41

Merged
chenjiahan merged 1 commit intorstackjs:mainfrom
colinaaa:colin/1127/pnp
Nov 27, 2025
Merged

fix: avoid import { logger } from '@rsbuild/core'#41
chenjiahan merged 1 commit intorstackjs:mainfrom
colinaaa:colin/1127/pnp

Conversation

@colinaaa
Copy link
Copy Markdown
Contributor

Currently, the @rsbuild/core is set as an optional peerDependency of this plugin.

However, there is import { logger } from '@rsbuild/core' in the output which would make @rsbuild/core a required peerDependency.

This would result in having error when using this plugin in a non-Rsbuild project (e.g.: an Rspeedy project) with strict dependencies installation (Yarn Plug'n'Play or Pnpm enableGlobalVirtualStore)

error   @rsbuild/plugin-type-check tried to access @rsbuild/core (a peer dependency) but it isn't provided by your application; this makes the require call ambiguous and unsound.

Required package: @rsbuild/core (via "@rsbuild/core/package.json")
Required by: @rsbuild/plugin-type-check@virtual:c4488a79c5c1f49499ecf693ac393dd0fc4431296e2bdce1090f58fe30867103fdd38742c848d55a8c452d6f320ed39864d28a2d132c954a79c27f334647c851#npm:1.2.4 (via /root/rspeedy-project/.yarn/__virtual__/@rsbuild-plugin-type-check-virtual-ad17be01ff/2/.yarn/berry/cache/@rsbuild-plugin-type-check-npm-1.2.4-feb9e4a14d-10c0.zip/node_modules/@rsbuild/plugin-type-check/dist/index.js)
Ancestor breaking the chain: rspeedy-project@workspace:.

In this patch, we use api.logger and fallback to console for old version of Rsbuild.

Another way would be bundling the logger into the output of the plugin :)

Copy link
Copy Markdown
Member

@chenjiahan chenjiahan left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@chenjiahan chenjiahan merged commit c3d0149 into rstackjs:main Nov 27, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants