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

feat: improve treeshakeability #5682

Merged
merged 2 commits into from Apr 13, 2022
Merged

feat: improve treeshakeability #5682

merged 2 commits into from Apr 13, 2022

Conversation

fnlctrl
Copy link
Member

@fnlctrl fnlctrl commented Apr 7, 2022

More /*#__PURE__*/ markers are added to improve treeshakeability. Intended for libaries that bundle vue.

Background

I was writing a library that exports some pure function and some UI-related function to render something. To make it standalone, vue is bundled. To simplify build setup and .d.ts generation, the whole library is bundled into one ESM file.

I created a test app with vite and found even when UI-related functions aren't imported (they depend on vue), the resulting app bundle contains some vue code that wasn't removed. This PR contains all that I could find that lacked /*#__PURE__*/ marking, and by adding these all unused code were correctly removed.

@netlify
Copy link

netlify bot commented Apr 7, 2022

Deploy Preview for vuejs-coverage ready!

Name Link
🔨 Latest commit c8cc62c
🔍 Latest deploy log https://app.netlify.com/sites/vuejs-coverage/deploys/6256996dc6894000083346ca
😎 Deploy Preview https://deploy-preview-5682--vuejs-coverage.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 settings.

@netlify
Copy link

netlify bot commented Apr 7, 2022

Deploy Preview for vue-next-template-explorer ready!

Name Link
🔨 Latest commit c8cc62c
🔍 Latest deploy log https://app.netlify.com/sites/vue-next-template-explorer/deploys/6256996e673d990009bda961
😎 Deploy Preview https://deploy-preview-5682--vue-next-template-explorer.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 settings.

@netlify
Copy link

netlify bot commented Apr 7, 2022

Deploy Preview for vue-sfc-playground ready!

Name Link
🔨 Latest commit c8cc62c
🔍 Latest deploy log https://app.netlify.com/sites/vue-sfc-playground/deploys/6256996ef5472800081a2f3a
😎 Deploy Preview https://deploy-preview-5682--vue-sfc-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 settings.

target.$.accessCache[key] = 0;
} else if (hasOwn(descriptor,'value')) {
target.$.accessCache[key] = 0
} else if (hasOwn(descriptor, 'value')) {
Copy link
Member Author

Choose a reason for hiding this comment

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

These lines are changed by prettier, not sure why they weren't formatted when initially merged.

@yyx990803 yyx990803 merged commit c6eb3cc into vuejs:main Apr 13, 2022
@fnlctrl fnlctrl deleted the treeshake branch April 13, 2022 11:26
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.

None yet

2 participants