antoniandre / wave-ui

A UI framework for Vue.js 3 (and 2) with only the bright side. ☀️
https://antoniandre.github.io/wave-ui
MIT License
546 stars 41 forks source link

Error with treeshaking vite and vue 3 #103

Closed basbroens closed 1 year ago

basbroens commented 1 year ago

I'm trying to use the treeshaking option, but on build a get an error:

Rollup failed to resolve import "wave-ui/src/wave-ui/components" from "C:/code/www/kdsv3/src/main.js".

Probably i'm doing something wrong with the file imports in main.js

`import WaveUI from 'wave-ui/src/wave-ui/core'

import { WButton } from 'wave-ui/src/wave-ui/components'; import { WDialog } from 'wave-ui/src/wave-ui/components';`

What am i missing? :)

antoniandre commented 1 year ago

Hi @basbroens, indeed, I will update the documentation shortly as index.js needs to be specified in wave-ui/src/wave-ui/components/index.js when used from outside of the Wave UI project.

Here is a StackBlitz demo where only the WButton, WAlert, WIcon components are loaded, and where using the w-rating component would raise a Vue warning saying the component is undefined.

The tree shaking will be done automatically on build when you don't import the components you don't need.

https://stackblitz.com/edit/waveui-3-tree-shaking?file=package.json,src%2Fmain.js,src%2FApp.vue

Hope this helps :)

antoniandre commented 1 year ago

Hi @basbroens I have also exposed the /components alias, so both paths will work now. cheers.

basbroens commented 1 year ago

thnx so much for your help