Skip to content

Fix React Aria Components tree shaking#4357

Merged
devongovett merged 2 commits into
mainfrom
rac-tree-shaking
Apr 10, 2023
Merged

Fix React Aria Components tree shaking#4357
devongovett merged 2 commits into
mainfrom
rac-tree-shaking

Conversation

@devongovett
Copy link
Copy Markdown
Member

Fixes #4356

Normally SWC inserts a PURE annotation comment on React forwardRef calls so that they can be tree-shaken when unused. But in the cases where we use a TypeScript cast this doesn't work, so all of those components end up getting included in application bundles even when not used. This PR adds the PURE annotation comments manually in those cases. A follow up could be to make SWC smarter about this.

snowystinger
snowystinger previously approved these changes Apr 10, 2023
Copy link
Copy Markdown
Member

@snowystinger snowystinger left a comment

Choose a reason for hiding this comment

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

just to make sure, this comment doesn't get removed by anything? I assume that minifiers are smart enough to not remove it and swc won't remove ones it didn't add?

@devongovett
Copy link
Copy Markdown
Member Author

I ran the build and the comment was preserved.

@rspbot
Copy link
Copy Markdown

rspbot commented Apr 10, 2023

@rspbot
Copy link
Copy Markdown

rspbot commented Apr 10, 2023

## API Changes

unknown top level export { type: 'identifier', name: 'Column' }
unknown top level export { type: 'identifier', name: 'Column' }
unknown type { type: 'link' }
unknown type { type: 'link' }
unknown type { type: 'link' }
unknown type { type: 'link' }
unknown type { type: 'link' }
unknown type { type: 'link' }

@devongovett devongovett merged commit 2784d3b into main Apr 10, 2023
@devongovett devongovett deleted the rac-tree-shaking branch April 10, 2023 22:22
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.

Very large size bundle size (80KB+) with only Button element (react-aria-components)

4 participants