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

Workaround RSP tree shaking issue with RAC #6301

Merged
merged 3 commits into from
May 1, 2024
Merged

Workaround RSP tree shaking issue with RAC #6301

merged 3 commits into from
May 1, 2024

Conversation

devongovett
Copy link
Member

@devongovett devongovett commented May 1, 2024

This avoids all of RAC Checkbox and its dependencies being included in RSP checkbox when building an app with Parcel. The underlying issue is a bug in SWC, the minifier used by Parcel. In the meantime, this workaround moves the contexts we import from RSP when not using the RAC implementation to a separate file so that only the contexts are included and not the entire implementation. I verified this is working in a test app.

export const ColorFieldContext = createContext<ContextValue<ColorFieldProps, HTMLDivElement>>(null);
export const ColorSliderContext = createContext<ContextValue<Partial<ColorSliderProps>, HTMLDivElement>>(null);
export const ColorWheelContext = createContext<ContextValue<Partial<ColorWheelProps>, HTMLDivElement>>(null);
export const HeadingContext = createContext<ContextValue<HeadingProps, HTMLHeadingElement>>({});
Copy link
Member Author

Choose a reason for hiding this comment

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

The most optimal thing to do would be to make each of these a separate file but that seemed a bit annoying. So if you import Checkbox you'll currently also get the other contexts, but they are tiny (one function call) so doesn't seem like a big deal.

@rspbot
Copy link

rspbot commented May 1, 2024

@rspbot
Copy link

rspbot commented May 1, 2024

@rspbot
Copy link

rspbot commented May 1, 2024

@rspbot
Copy link

rspbot commented May 1, 2024

## API Changes

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

@LFDanLu LFDanLu merged commit ec7c614 into main May 1, 2024
25 checks passed
@LFDanLu LFDanLu deleted the fix-tree-shaking branch May 1, 2024 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants