Addepar / ember-widgets

https://opensource.addepar.com/ember-widgets/#/ember-widgets/overview
Other
290 stars 79 forks source link

Make it easy to include components individually #68

Open azirbel opened 10 years ago

azirbel commented 10 years ago

Discussion from https://github.com/Addepar/ember-widgets/issues/19: "The files should be structured in such a way that to just use the couple of components only (not whole ember-widgets), the inclusion of the features should be very light and isolated."

Ideally, there would be a way to include just a few components, and avoid unnecessary dependencies/large amounts of code from other components.

lstrzebinczyk commented 9 years ago

I have created a small gem available at https://github.com/KillaPL/ember_widgets_rails to simplify rails integration. I only need carousel widget and this is the only one available in the gem right now. However, the ability to include components individually is possible to achieve using sprockets, as I've done in the gem. If you'd like, I can try sending a pull request to achieve the same effect here.

azirbel commented 9 years ago

I'd be interested to hear more, but I don't have enough rails background to understand how your gem works or whether your approach would be applicable here. Could you explain, or just make a rough PR so I can get an idea of what it would look like?

Alternatively - @bigsley may have a better understanding, since he's worked more with rails.

lstrzebinczyk commented 9 years ago

Sorry for the delay.

Basically sprockets works my adding so colled directives, and then proprocessing files. Preprocessing concatenates all requested files into one. When developing web apps it allows to work on separate files for separate concerns, and deploy a single file to production.

If you take a look at https://github.com/KillaPL/ember_widgets_rails, you will notice that all I did was, I copied whole repo from here and created file like this:

#= require ../origin/ember_widgets
#= require ../origin/src/carousel
#= require ../origin/src/templates/carousel
#= require_self

(+ some templates setting up not related to this problem)

If this file was compiled by itself, it would provide a standalone file with carousel widget. If some widgets use common files, the common is obviously only included once, so it's a good way to provide standalone, and smallest possible file with expected widgets.

It should be even possible to create an automated source generator with it, something like bootstrap has.