-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
feat: add sideeffects to addons; #29841
base: next
Are you sure you want to change the base?
Conversation
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.
19 file(s) reviewed, 5 comment(s)
Edit PR Review Bot Settings | Greptile
@@ -43,6 +43,7 @@ | |||
}, | |||
"main": "dist/index.js", | |||
"module": "dist/index.mjs", | |||
"sideEffects": false, |
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.
style: Consider setting sideEffects to ['./dist/manager.js'] since manager entries often have initialization side effects
@@ -75,6 +75,7 @@ | |||
}, | |||
"main": "dist/index.js", | |||
"module": "dist/index.mjs", | |||
"sideEffects": false, |
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.
style: Consider setting sideEffects to an array of framework-specific files that do have side effects instead of false
@@ -75,6 +75,7 @@ | |||
}, | |||
"main": "dist/index.js", | |||
"module": "dist/index.mjs", | |||
"sideEffects": false, |
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.
logic: Consider checking if any of the bundled addons (actions, backgrounds, controls etc.) have initialization side effects that need to be preserved. May need to be sideEffects: ["./dist/*/preview.js"]
instead of false
.
@@ -32,6 +32,7 @@ | |||
}, | |||
"main": "dist/index.js", | |||
"module": "dist/index.mjs", | |||
"sideEffects": false, |
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.
logic: react-confetti, framer-motion, and react-joyride may have side effects. Consider checking if these dependencies require side effects to function properly before marking the entire package as side-effect free.
@@ -65,6 +65,7 @@ | |||
}, | |||
"main": "dist/index.js", | |||
"module": "dist/index.mjs", | |||
"sideEffects": false, |
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.
logic: Setting sideEffects to false here may be problematic since this addon has setup files, global setup, and postinstall scripts that likely have side effects. Consider reviewing the actual side effects in the codebase before marking as side-effect free.
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.
19 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings | Greptile
@@ -42,6 +42,7 @@ | |||
}, | |||
"main": "dist/index.js", | |||
"module": "dist/index.mjs", | |||
"sideEffects": false, |
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.
logic: axe-core and accessibility testing setup often requires initialization side effects - verify that tree-shaking doesn't break the accessibility testing functionality
☁️ Nx Cloud ReportCI is running/has finished running commands for commit 70f10ba. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution ✅ Successfully ran 1 targetSent with 💌 from NxCloud. |
Package BenchmarksCommit: The following packages have significant changes to their size or dependencies:
|
Before | After | Difference | |
---|---|---|---|
Dependency count | 105 | 102 | 🎉 -3 🎉 |
Self size | 42 KB | 41 KB | 🎉 -435 B 🎉 |
Dependency size | 18.01 MB | 17.86 MB | 🎉 -154 KB 🎉 |
Bundle Size Analyzer | Link | Link |
What I did
Add side effects to package.json, help bundlers cut unused code with treeshake. Good for esm, modules, named imports.
rollup https://rollupjs.org/configuration-options/#treeshake-modulesideeffects
webpack https://webpack.js.org/guides/tree-shaking/#mark-the-file-as-side-effect-free
Checklist for Maintainers
When this PR is ready for testing, make sure to add
ci:normal
,ci:merged
orci:daily
GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found incode/lib/cli-storybook/src/sandbox-templates.ts
Make sure this PR contains one of the labels below:
Available labels
bug
: Internal changes that fixes incorrect behavior.maintenance
: User-facing maintenance tasks.dependencies
: Upgrading (sometimes downgrading) dependencies.build
: Internal-facing build tooling & test updates. Will not show up in release changelog.cleanup
: Minor cleanup style change. Will not show up in release changelog.documentation
: Documentation only changes. Will not show up in release changelog.feature request
: Introducing a new feature.BREAKING CHANGE
: Changes that break compatibility in some way with current major version.other
: Changes that don't fit in the above categories.🦋 Canary release
This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the
@storybookjs/core
team here.core team members can create a canary release here or locally with
gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=<PR_NUMBER>
Greptile Summary
Added
sideEffects: false
to multiple Storybook addon package.json files to enable better tree-shaking optimization, with potential risks identified in certain addons.💡 (1/5) You can manually trigger the bot by mentioning @greptileai in a comment!