epicmaxco / epic-spinners

Easy to use css spinners collection with Vue.js integration
https://epic-spinners.epicmax.co
3.84k stars 357 forks source link

Importing a single spinner adds the entire collection of spinners to prod build #25

Closed chriszrc closed 5 years ago

chriszrc commented 5 years ago

If I include a single spinner in my vue cli 3 project:

import bButton from 'bootstrap-vue/es/components/button/button';

import { HalfCircleSpinner } from 'epic-spinners';

@Component({
  components:{
    bButton,
    HalfCircleSpinner,
  },
})
//etc

This is what I see in the source-map explorer after executing a build:prod

screen shot 2019-01-08 at 9 56 44 am

I would have expected that given I'm only including a single component, and that component doesn't depend on the other spinners, that I'd be able to import it singly?

RDelorier commented 5 years ago

I'm getting the same result on an inherited project, it uses just 1 spinner and is the largest dependency.

screen shot 2019-01-24 at 4 11 52 am

RDelorier commented 5 years ago

nvm I just imported the component directly and it fixed it

// before 
import {PixelSpinner} from 'epic-spinners'

// after
import PixelSpinner from 'epic-spinners/src/components/lib/PixelSpinner'

screen shot 2019-01-24 at 4 17 25 am

chriszrc commented 5 years ago

@RDelorier yay! confirmed, I see it working here on my project as well-

asvae commented 5 years ago

Importing file is the only way to get correct tree-shaking from current build.

Added the instruction to the docs.

We also plan more fundamental solution for the problem and it's moved to #32