Skip to content
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

Display warning on reexporting in shared public API large size module that affects bundle size #137

Open
ratomiru opened this issue Dec 3, 2024 · 1 comment
Labels
PRIORITY | LOW Can wait until after release TYPE | enhancement New feature or request

Comments

@ratomiru
Copy link

ratomiru commented Dec 3, 2024

Problem

According to "Large bundles and broken tree-shaking in Shared", there may be some cases where one shared module size is extremely large. In these cases using something like button on page 1 can lead to downloading whole big heavy package like drag'n'drop library which is intended for page 2

Solution

It would be nice to check total external packages size a reexported file uses. I am not sure, is it possible technically, so I just share the idea

Some points

Example

/shared/ui
    button.tsx // chakra-ui: 54k, total: 54k
    date-picker.tsx // chakra-ui: 54k, dayjs: 8k, total: 62k
    code-editor // @codeium/react-code-editor: 4mb, total: 4mb

shared/ui/index.ts

export { Button } from './button'
export { DatePicker } from './date-picker'
export { CodeEditor } from './code-editor' // 4mb is quite heavy so linter will show warning
@illright
Copy link
Member

illright commented Dec 3, 2024

That's an interesting idea, thanks! Would be interesting to explore this from the performance perspective. Another question is how relevant this diagnostic is for modern bundlers like Vite or esbuild. We should do some testing here to identify if this rule would actually help people avoid excessively large bundles due to FSD's public API rules.

@illright illright added TYPE | enhancement New feature or request PRIORITY | LOW Can wait until after release labels Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PRIORITY | LOW Can wait until after release TYPE | enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants