-
-
Notifications
You must be signed in to change notification settings - Fork 58
feat: default exclude @types/react from dts bundle
#1365
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
24e9fba to
0047b60
Compare
0047b60 to
3503398
Compare
✅ Deploy Preview for rslib ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for rslib 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 implements automatic exclusion of @types/react from declaration file bundles. Previously, when a React component library had @types/react in devDependencies but not in peerDependencies, Rslib would bundle it into the declaration output files according to the autoExternal logic. This PR fixes that behavior by introducing a default exclusion list.
Key Changes:
- Added
DEFAULT_EXCLUDED_PACKAGESconstant containing@types/reactto automatically exclude it from dts bundles - Updated documentation to reflect the change and generalize examples from
@types/reactto@types/foo - Modified
react-component-bundleexample to enabledts.bundleto demonstrate the feature
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
packages/plugin-dts/src/dts.ts |
Introduces DEFAULT_EXCLUDED_PACKAGES constant and filters bundled packages to exclude default packages |
packages/plugin-dts/tests/external.test.ts |
Updates test setup to include default excluded packages in mock data for all tests |
website/docs/en/guide/faq/features.mdx |
Corrects documentation links from #outputtarget to #outputexternals and updates example from @types/react to @types/foo |
website/docs/zh/guide/faq/features.mdx |
Chinese translation of the same documentation updates |
examples/react-component-bundle/rslib.config.ts |
Enables dts.bundle and comments out CJS format to demonstrate the feature |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
fi3ework
left a comment
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.
in terms of the best practice, do we need to add @types/react to peer deps in our template?
In fact, almost all tool templates don't include I prefer to temporarily not add them to peer deps in the templates, and we just handle |
Summary
@types/react.@types/reactinpeerDependenciesbut only indevDependencies. Following the autoExternal logic for dependency handling, Rslib will attempt to bundle@types/reactinto the declaration output files during the build. However, in practice, a component library should not bundle@types/react.In this PR, default exclude
@types/reactfrom dts bundle.Related Links
Checklist