therufa / mdi-vue

Material design icons for vue.js
https://www.npmjs.com/package/mdi-vue
MIT License
88 stars 13 forks source link

Feature suggestion: named exports instead of default #4

Closed robcresswell closed 6 years ago

robcresswell commented 6 years ago

Hey, I had another idea which would clean up the usage of this lib a bit. Currently, when you want to use several icons, its a full line per icon; it gets fairly verbose quite quickly. Have you given any thought to altering the structure so that instead of having an export per file, you have multiple named exports in one file?

Then instead of:

import 'mdi-vue/CommentAlertIcon';
import 'mdi-vue/AccountIcon';
import 'mdi-vue/FaceIcon';

You could have:

import { Comment, Account, Face } from 'mdi-vue'

This would also work rather nicely with removing the global component declaration for each component. Rather than manually naming them in that way, people could use the lib like:

import { Comment, Account, Face } from 'mdi-vue'

components: {
  "face-icon": Face,
  "account-icon": Account,
  "comment-icon": Comment
}

Would love to hear your thoughts on designing like this. If you don't agree, I'm happy to fork and do my own thing; it's just a suggestion :)

therufa commented 6 years ago

@robcresswell thanks for your input on this issue. Its a very interesting question because of the size of the library. At the moment we sit on roughly 8-9 Mb of icon components when the entire lib is compiled. I have no idea how these preloaders work, but i think they could do the trick, sadly i had no time to try out these things. Maybe this weekend.

I'm open to any input on this topic by the way. Always happy to learn, you know. :)

robcresswell commented 6 years ago

I honestly have no idea either; my hope would that the entire module isn't included (as you note, that would be way too big). This is really all just me thinking out loud though, so please don't use up your weekend or other spare time on my count, as the library works perfectly well as it is. If you do spend some time experimenting, I'd love to see what comes out of it.