algolia / algolia/instantsearch

Tree Shaking with Vite not working

Open
#5,385 2 comments 1 reaction 0 assignees View on GitHub
Library: Vue InstantSearch
Dominant language
TypeScript
Stars
4.1k
Forks
553
Avg merge
1d 11h
Merged PRs (30d)
51

Description

**Bug 🐞**

### What is the current behavior?
To reduce bundle-size, I follow the documentation recommandation : https://www.algolia.com/doc/guides/building-search-ui/going-further/improve-performance/vue/?client=Vue+3#optimize-build-size

When running `npm run build`, all vue-instantsearch is compiled whereas I simply do `import 'vue-instantsearch/vue3/es';` in counter.js file.

### Make a sandbox with the current behavior
https://stackblitz.com/edit/vitejs-vite-nyimj5?file=counter.js&terminal=dev

### What is the expected behavior?
`import 'vue-instantsearch/vue3/es';` in counter.js file should import nothing

### What is the proposed solution?
What is your recommandation to make tree-shaking working ?

### What is the version you are using?
"vue-instantsearch": "^4.6.0"

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the behavior in the linked StackBlitz sandbox and inspect the import in counter.js for vue-instantsearch/vue3/es. Compare the Vite build output with the expected unused-code elimination; done means the build excludes unused vue-instantsearch code or documents the required tree-shaking configuration.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, vite
Domain
build-system, frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.