{"action":"created","issue":{"url":"https://api.github.com/repos/PaulUithol/Backbone-relational/issues/528","labels_url":"https://api.github.com/repos/PaulUithol/Backbone-relational/issues/528/labels{/name}","comments_url":"https://api.github.com/repos/PaulUithol/Backbone-relational/issues/528/comments","events_url":"https://api.github.com/repos/PaulUithol/Backbone-relational/issues/528/events","html_url":"https://github.com/PaulUithol/Backbone-relational/issues/528","id":83151192,"number":528,"title":"Backbone-relational + Browserify","user":{"login":"davekiss","id":1256071,"avatar_url":"https://avatars.githubusercontent.com/u/1256071?v=3","gravatar_id":"","url":"https://api.github.com/users/davekiss","html_url":"https://github.com/davekiss","followers_url":"https://api.github.com/users/davekiss/followers","following_url":"https://api.github.com/users/davekiss/following{/other_user}","gists_url":"https://api.github.com/users/davekiss/gists{/gist_id}","starred_url":"https://api.github.com/users/davekiss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davekiss/subscriptions","organizations_url":"https://api.github.com/users/davekiss/orgs","repos_url":"https://api.github.com/users/davekiss/repos","events_url":"https://api.github.com/users/davekiss/events{/privacy}","received_events_url":"https://api.github.com/users/davekiss/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-05-31T18:14:24Z","updated_at":"2015-06-01T05:44:41Z","closed_at":null,"body":"Has anyone been able to successfully get Backbone-relational working with Browserify? I'm at 3 days of hacking with no luck. Been getting all kinds of errors, but these are the most common (they are untrue):\r\n\r\n`Relation=s: relatedModel does not inherit from Backbone.RelationalModel (s).`\r\n`collectionType must inherit from Backbone.Collection`\r\n\r\nI've already seen `addModelScope( models );` but it doesn't seem to solve the issues. Would I need to use that in every module I create? I was trying something like this:\r\n\r\n```\r\nvar models      = window.Namespace.models      = window.Namespace.models      || {};\r\nvar collections = window.Namespace.collections = window.Namespace.collections || {};\r\nBackbone.Relational.store.addModelScope( models );\r\n\r\nmodels.Course = require('../models/course_model');\r\nvar course = new models.Course( Namespace.courses[0] );\r\n```\r\n\r\nI'm guessing this is some kind of scoping issue but I am at a loss as to how to get this set up properly in this type of environment. If you've done it successfully, can you post your Browserify recipe or strategy?"},"comment":{"url":"https://api.github.com/repos/PaulUithol/Backbone-relational/issues/comments/107315524","html_url":"https://github.com/PaulUithol/Backbone-relational/issues/528#issuecomment-107315524","issue_url":"https://api.github.com/repos/PaulUithol/Backbone-relational/issues/528","id":107315524,"user":{"login":"Narsul","id":898027,"avatar_url":"https://avatars.githubusercontent.com/u/898027?v=3","gravatar_id":"","url":"https://api.github.com/users/Narsul","html_url":"https://github.com/Narsul","followers_url":"https://api.github.com/users/Narsul/followers","following_url":"https://api.github.com/users/Narsul/following{/other_user}","gists_url":"https://api.github.com/users/Narsul/gists{/gist_id}","starred_url":"https://api.github.com/users/Narsul/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Narsul/subscriptions","organizations_url":"https://api.github.com/users/Narsul/orgs","repos_url":"https://api.github.com/users/Narsul/repos","events_url":"https://api.github.com/users/Narsul/events{/privacy}","received_events_url":"https://api.github.com/users/Narsul/received_events","type":"User","site_admin":false},"created_at":"2015-06-01T05:44:41Z","updated_at":"2015-06-01T05:44:41Z","body":"Hey. Well I have a file ```app_loader.js``` which is my entry point to entire app.\r\nIn it I'm doing all the hacks to support some nasty plugins etc.\r\n\r\nTry to browserify this:\r\n```\r\nvar $ = require('jquery');                                  // jQuery\r\nvar Backbone = require('backbone');                         // Backbone\r\nBackbone.$ = $;                                             // Setting jQuery as Backbone's DOM library\r\nrequire('backbone-relational');                             // Backbone relational plugin\r\n\r\nvar models = {};\r\nBackbone.Relational.store.addModelScope(models);\r\n\r\nmodels.Person = Backbone.RelationalModel.extend({\r\n    relations: [{\r\n        type: 'HasOne',\r\n        key: 'address',\r\n        relatedModel: 'Address',\r\n        keySource: 'addressId'\r\n    }]\r\n});\r\nmodels.Address = Backbone.RelationalModel.extend({});\r\n\r\nvar john = models.Person.findOrCreate({id: 1, firstName: 'John', lastName: 'Smith', addressId: 2});\r\nvar home = models.Address.findOrCreate({id: 2, name: 'home', street: '...'});\r\n\r\nconsole.log(john.toJSON());\r\n```"}}