Template breaks asterisk tree-shaking?
Version
3.2.26
Reproduction link
Steps to reproduce
- Import module with asterisk,
import * as tree from './tree-shaking2'
- Use imported var in template
{{ tree.used2() }}
- Build with vite build
- 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
asmaybeRef
, hitting theunref
logic. tree.used2()
turns intounref(tree).used2()
.- The
unref()
call breaks tree shaking.