Skip to content

Conversation

@EHLOVader
Copy link

I ran into issues with $.isotope being undefined and realized it is becuase the dependencies in the bower.json were only devDeps and thus weren't wired into the web app appropriately when I ran my build.

This moves the two dependencies out of dev since they are both required for proper use of the jquery plugin and are in fact included in the packaged version of the code.

@desandro
Copy link
Member

Thanks for taking a look at this. jQuery support is a complex issue.

Yes, jQuery Bridget is included with isotope.pkgd.js, as I believe most developers who use this file probably want the convenience of jQuery.

However, jQuery is not an explicit dependency of Isotope. This allows Isotope to be used with vanilla JS.

The complication is with package management like Browserify or require.js. In order to use the jQuery plugin of Isotope, $(elem).isotope(), with these, you'll have to add extra code to wire up jQuery Bridget. I have discussed this in the RequireJS and Browserify documentation.

I realize this is complicated. But I feel it's the best solution that allows for the most flexibility.

@EHLOVader
Copy link
Author

Ah I saw those, but didn't know what to do for wiredep. Perhaps I will look into custom bower.json for my project and it could mitigate this issue.

If I find something I will contribute for documentation.

@EHLOVader
Copy link
Author

Ok, so I researched this and it appears that using bower's overrides works so I can solve the bower dependency wiredep issue I had.

Here is the override in my bower to share:

  "overrides": {
    "isotope": {
      "main": [
        "js/item.js",
        "js/layout-mode.js",
        "js/isotope.js",
        "js/layout-modes/vertical.js",
        "js/layout-modes/fit-rows.js",
        "js/layout-modes/masonry.js"
      ],
      "dependencies": {
        "get-size": ">=1.1.8 <1.3",
        "matches-selector": ">=1 <2",
        "outlayer": "1.3.x",
        "masonry": "3.2.x",
        "jquery": ">=1.4.3 <2",
        "jquery-bridget": "1.1.x"
      }
    },
    "outlayer": {
      "main": [
        "item.js",
        "outlayer.js"
      ]
    }
  }

EDIT: Updated my json to reflect the changes that have been made to both isotope and outlayer regarding the main of their bower.json files.

@thedamon
Copy link

Was having the same issue. Following @EHLOVader, I added those overrides, and then jquery-bridget to my own dependencies. I think that should sort it! Very glad I found this issue or I would have been running around in circles for a long time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants