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

Template breaks asterisk tree-shaking? #5209

Closed
OpenGG opened this issue Jan 5, 2022 · 0 comments
Closed

Template breaks asterisk tree-shaking? #5209

OpenGG opened this issue Jan 5, 2022 · 0 comments
Labels
🍰 p2-nice-to-have Priority 2: this is not breaking anything but nice to have it addressed. scope: script-setup

Comments

@OpenGG
Copy link

OpenGG commented Jan 5, 2022

Version

3.2.26

Reproduction link

stackblitz.com

snap

Steps to reproduce

  1. Import module with asterisk, import * as tree from './tree-shaking2'
  2. Use imported var in template {{ tree.used2() }}
  3. Build with vite build
  4. Checkout output files

What is expected?

Only tree.used2() will be found in bundle

What is actually happening?

All exports from 'tree-shaking2.ts', even those not used, like tree.notUsed2() will be present in bundle.


Dig in sfc compiler.

Possible cause:

  • Compiler detects tree as maybeRef, hitting the unref logic.
  • tree.used2() turns into unref(tree).used2().
  • The unref() call breaks tree shaking.
@yyx990803 yyx990803 added the 🍰 p2-nice-to-have Priority 2: this is not breaking anything but nice to have it addressed. label Jan 16, 2022
iwusong pushed a commit to iwusong/core that referenced this issue May 13, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Sep 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🍰 p2-nice-to-have Priority 2: this is not breaking anything but nice to have it addressed. scope: script-setup
Projects
None yet
Development

No branches or pull requests

3 participants