Abitlity to sort assets within a bundle#344
Abitlity to sort assets within a bundle#344jdarais wants to merge 7 commits intomiracle2k:masterfrom
Conversation
|
I like this quite a bit. Still, there are some thoughts I have:
There is #139 for a real sprockets-system (and vaguely #240 might provide inspiration), but thinking about it now, I don't think it easy at all to add this to webassets. How would it interact with the bundle hierarchies (boy do I want to get rid of those)? This sorting approach may be a good middle ground approach. |
|
Yeah, the way this interacts with caching is not great. I'm not too familiar with the caching mechanisms, but it seems that to trigger a re-resolve of the contents list, we would at least need to check timestamps on files and re-resolve if a file has been edited. It would probably be overkill to parse the files each time to find out if the edit involved a dependency change. On your second point, that's correct that you still need to list all the files in your bundle. In my own project, that's not much of a problem, since my js files are grouped inside of folders, and I can just include the folder names with a glob pattern. (Actually, it would be no problem at all if the resolver supported recursive glob patterns like js/*/.js) The only problem with this approach is that you don't get the benefit of pruning off js files that aren't actually needed. I'm not sure this would be the ideal solution for doing a sprockets-like resolve which finds and includes dependencies in addition to sorting. I'll see if I can play around with some of these ideas to improve upon the concept. |
|
I would love to have a dependency resolver, but I think webassets needs a redesign for it. |
Hi, I realize you've been working on require.js support, but I also like how Sprockets in the Rails asset pipeline is able to combine js files while taking dependencies into account by looking for a ("//= require <dep.js>") directive in the js file. It's a bit simpler if all you need is the ability to break your js into a file hierarchy and specify dependencies between files.
I implemented this for a small project of mine, and I thought I should share in case you're interested in incorporating it into your own branch. It just adds a new extension point in the bundle code, and the rest is implemented as a sort extension.
Thanks