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

withDefaults object variable results in non-tree-shakable component #9500

Closed
94726 opened this issue Oct 30, 2023 · 0 comments · Fixed by #9507
Closed

withDefaults object variable results in non-tree-shakable component #9500

94726 opened this issue Oct 30, 2023 · 0 comments · Fixed by #9507
Labels
🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. scope: compiler

Comments

@94726
Copy link

94726 commented Oct 30, 2023

Vue version

3.3.4

Link to minimal reproduction

https://stackblitz.com/edit/vitejs-vite-3cmbr7?file=dist%2Fassets%2Findex-311591ca.js

Steps to reproduce

  1. npm run build
  2. open dist/assets/index-....js and scroll to the bottom
  3. see bundled NonTreeshakable

What is expected?

Component should be tree-shaken

What is actually happening?

Component isn't tree-shaken because it compiles to

/* @__PURE__ */ defineComponent({
  __name: "NonTreeshakable",
  props: mergeDefaults({
    prop1: { type: Boolean },
    prop2: {}
  }, propsDefaults),
  setup(__props) {
    ...
  }
});

mergeDefaults ends up being used at the top level and isn't marked as sideEffect-free.

System Info

No response

Any additional comments?

I ran into this after looking into why radix-vue seems way too large compared to how small my imported components are.
Their PopperContent.vue leads to this exact problem.

@haoqunjiang haoqunjiang added 🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. scope: compiler labels Oct 30, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Dec 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. scope: compiler
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants