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

chore: add #__NO_SIDE_EFFECTS__ notation to defineStore #2740

Merged
merged 2 commits into from
Aug 15, 2024

Conversation

serkodev
Copy link
Contributor

Fix #2738

In defineStore, certain behaviors of createSetupStore and createOptionsStore might prevent the bundler from performing static analysis to determine whether there are any side effects.

Therefore, in this PR, the defineStore function is marked as having no side effects, enabling the bundler to tree-shake stores that are not used after being defined.

References

https://github.com/javascript-compiler-hints/compiler-notations-spec/blob/main/no-side-effects-notation-spec.md
rollup/rollup#5024

Copy link

netlify bot commented Aug 15, 2024

Deploy Preview for pinia-official canceled.

Name Link
🔨 Latest commit aff11e7
🔍 Latest deploy log https://app.netlify.com/sites/pinia-official/deploys/66be3cff016c8600083c98c3

Copy link

netlify bot commented Aug 15, 2024

Deploy Preview for pinia-playground ready!

Name Link
🔨 Latest commit aff11e7
🔍 Latest deploy log https://app.netlify.com/sites/pinia-playground/deploys/66be3cff19efcb0008f4517d
😎 Deploy Preview https://deploy-preview-2740--pinia-playground.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Member

@posva posva left a comment

Choose a reason for hiding this comment

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

Thanks a lot! So there is a way to improve it!

packages/pinia/src/store.ts Outdated Show resolved Hide resolved
@posva posva merged commit 3069105 into vuejs:v2 Aug 15, 2024
4 checks passed
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 does not work when using multiple stores in Nuxt
2 participants