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

added a more detailed example for tree-shaking clarification #7593

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Vansh5632
Copy link
Contributor

@Vansh5632 Vansh5632 commented Mar 19, 2025

Enhance Tree Shaking Documentation with Full Example

This PR enhances the tree shaking documentation by adding a comprehensive section that explains side effects in more detail with a practical example.
Fixes: #7414

Changes

  • Added a new section "Full Example: Understanding Side Effects with CSS Files" that demonstrates:

    • A complete directory structure for a fictional UI component library
    • Content of key files including CSS files that constitute side effects
    • What happens when webpack processes imports with different sideEffects configurations
    • The specific impact of incorrectly marking files with side effects
  • Added a "Common Pitfalls with Side Effects" section covering:

    • Over-optimistic use of sideEffects: false
    • Issues with re-exports containing side effects
    • Problems with nested dependencies
    • Testing pitfalls in development mode

Rationale

The existing documentation uses the Shopify Polaris example but doesn't provide enough context about the full structure of the files, making it challenging for readers to understand the practical implications of the sideEffects flag.

This enhancement gives readers a more concrete example that shows the direct impact of incorrect side effects configuration (particularly for CSS files) and provides guidance on how to diagnose and fix these issues.

Copy link

vercel bot commented Mar 19, 2025

@Vansh5632 is attempting to deploy a commit to the OpenJS Foundation Team on Vercel.

A member of the Team first needs to authorize it.

@Vansh5632 Vansh5632 force-pushed the tree-shaking-clarification branch from 492de27 to 68cc665 Compare March 20, 2025 19:00
Copy link
Member

@alexander-akait alexander-akait left a comment

Choose a reason for hiding this comment

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

/cc @snitin315 Can you look why ci failed?

@snitin315
Copy link
Member

checking...

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.

Tree shaking clarification
3 participants