Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

isotope is borked #376

Closed
lifeiscontent opened this issue Sep 12, 2016 · 5 comments
Closed

isotope is borked #376

lifeiscontent opened this issue Sep 12, 2016 · 5 comments
Assignees

Comments

@lifeiscontent
Copy link

the instructions on rails-assets is wrong for isotope

I had to include all of these before I could get it to stop throwing errors.

//= require fizzy-ui-utils
//= require get-size
//= require ev-emitter
//= require outlayer/item.js
//= require outlayer/outlayer.js
//= require isotope/item.js
//= require isotope/layout-mode.js
//= require isotope/layout-modes/fit-rows.js
//= require isotope/isotope.js

there's probably an abstraction upstream I'm assuming that just hasn't been applied for this module?

@hut8 hut8 self-assigned this Sep 12, 2016
@hut8
Copy link
Member

hut8 commented Sep 12, 2016

If these files aren't concatenated and included in the main part of bower.json, then they won't be included automatically. This is pretty confusing; I'll admit. Can you refer to #362 and tell me if that would solve your issue?

@lifeiscontent
Copy link
Author

@hut8 This isn't a perfect solution, but it'd help with hunting down what's needed to move forward I guess 👍

@hut8 hut8 closed this as completed Sep 15, 2016
@mattscilipoti
Copy link

mattscilipoti commented Nov 18, 2016

I am having the same issue, but I haven't found the right incantation of dependencies that will work. I've tried a few versions (2.2.2, 3.x). I don't understand how #362 can help me with this problem. I see a few related, closed issues but I don't understand the workarounds they recommend. One said, "Just require isotope and all its dependencies in correct order." Just? I am a bit confused. I'm late to the rails-assets party and still need to learn more about bower, but I thought that managing dependencies was a feature of the package manager. I suspect there is something simple here that you assume everyone knows, but I am not privy. Could you direct me to some documentation that can help me identify what specifically I need to do in rails, in what order, to support isotope via rails-assets-isotope? And how to update it to the next version? I appreciate it.

@hut8
Copy link
Member

hut8 commented Nov 18, 2016

Hey @mattscilipoti

I apologize and hear your frustration. The root of the problem here is that Bower has this a main section in bower.json which is intended to aid build tools (like rails-assets.org) in including the right files. There are an enormous number of packages which do not follow the suggestions put in the spec, and even if they did, it's still really hard for rails-assets to be able to give you a single file for each type (i.e., one CSS, one JS, etc). As you can see, the main part is technically optional to begin with and therefore it cannot be relied upon.

bower.json is a spec which has changed quite a bit, and now it recommends that the files in main not be built versions. This is definitely frustrating for us. To me, it seems like they should be built. Otherwise, the "build tool" has to support every build system, and the bower.json format has no data about how to build each package. And of course that's not easy to figure out -- most projects have some custom build command in a package.json script, and although it's often called build, that's just a convention, and in my experience this command is usually influenced by a number of environment variables (including NODE_ENV).

When you referred to:

Just require isotope and all its dependencies in correct order.

I think this was supposed to mean that the files inside of the isotope package need to be included appropriately. Looking at https://github.com/metafizzy/isotope/blob/master/bower.json#L4, it specifies (correctly) that there is one file that includes all the dependencies: https://github.com/metafizzy/isotope/blob/master/js/isotope.js -- the issue here, though, is that this code is what gets run in the browser: https://github.com/metafizzy/isotope/blob/master/js/isotope.js#L48 -- not the CommonJS or AMD versions. So therefore those identifiers (e.g., window.Outlayer) need to be defined before this file. If isotope.js would include the built version in main, then it would likely work fine: https://github.com/metafizzy/isotope/blob/master/dist/isotope.pkgd.js

Ultimately, this means that occasionally (for packages which do not include built assets in main), you will have to just "figure it out" since the bower.json format doesn't include enough data for tools like rails-assets to do something smarter. In this case, that means including some JS files that are present in the .gem, but finding those currently requires actually opening the gem directory and poking around the assets folder. That's the part that #362 would help with.

@mattscilipoti
Copy link

Thanks you for your amazing response. That was helpful for me (and I assume others in this predicament). I was aware that I had more to learn, but I wasn't sure where to start. I apologize for my delayed response. You should have received immediate positive feedback for that effort.

Configuration is always a balance. I hope that future work on bower and practices around it will keep this experience in mind. I wonder if rails-assets can be used to help surface and highlight these issues across the libraries you support? Currently, there is no indication which ones will "just work" (some do) and which ones require a deeper understanding of how this particular package chose to manage/configure bower.

Thanks again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants