{"action":"created","issue":{"url":"https://api.github.com/repos/gridstack/gridstack.js/issues/643","repository_url":"https://api.github.com/repos/gridstack/gridstack.js","labels_url":"https://api.github.com/repos/gridstack/gridstack.js/issues/643/labels{/name}","comments_url":"https://api.github.com/repos/gridstack/gridstack.js/issues/643/comments","events_url":"https://api.github.com/repos/gridstack/gridstack.js/issues/643/events","html_url":"https://github.com/gridstack/gridstack.js/issues/643","id":224404338,"node_id":"MDU6SXNzdWUyMjQ0MDQzMzg=","number":643,"title":"When used in browserify, gridstack is not correctly exported, which breaks the gridstack jquery drag plugin","user":{"login":"jaapz","id":513050,"node_id":"MDQ6VXNlcjUxMzA1MA==","avatar_url":"https://avatars0.githubusercontent.com/u/513050?v=4","gravatar_id":"","url":"https://api.github.com/users/jaapz","html_url":"https://github.com/jaapz","followers_url":"https://api.github.com/users/jaapz/followers","following_url":"https://api.github.com/users/jaapz/following{/other_user}","gists_url":"https://api.github.com/users/jaapz/gists{/gist_id}","starred_url":"https://api.github.com/users/jaapz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jaapz/subscriptions","organizations_url":"https://api.github.com/users/jaapz/orgs","repos_url":"https://api.github.com/users/jaapz/repos","events_url":"https://api.github.com/users/jaapz/events{/privacy}","received_events_url":"https://api.github.com/users/jaapz/received_events","type":"User","site_admin":false},"labels":[{"id":325603827,"node_id":"MDU6TGFiZWwzMjU2MDM4Mjc=","url":"https://api.github.com/repos/gridstack/gridstack.js/labels/status:need%20more%20info","name":"status:need more info","color":"d4c5f9","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2017-04-26T09:35:40Z","updated_at":"2018-10-08T07:31:36Z","closed_at":null,"author_association":"NONE","body":"I'm trying to move from 0.2.x to 0.3.0, however the module exporting code is not compatible with Browserify (or probably any CommonJS system).\r\n\r\nThe jQueryUI drag and drop plugin never correctly initializes.\r\n\r\nThis is because it is calling \r\n```javascript\r\ntry { GridStackUI = require('gridstack'); } catch(e) {}\r\n```\r\n\r\nWhich always returns an empty object, because the `gridstack.js` file **never actually exports anything**, but instead \"exports\" to the global `window` scope, as seen in `gridstack.js` line 20:\r\n\r\n```javascript\r\nvar scope = window;\r\n```\r\n\r\nAnd `gridstack.js` line 1729:\r\n\r\n```javascript\r\nscope.GridStackUI = GridStack;\r\n```\r\n\r\n`exports` is never actually used, so calling `require('gridstack')` will then always return an empty object.\r\n\r\nSo I think the module loading code for both `gridstack.js` and `gridstack.jQueryUI.js` should be altered to export using the `module.exports` CommonJS pattern.\r\n\r\nI think a good way to do this is looking at [how backbonejs does this](https://github.com/jashkenas/backbone/blob/master/backbone.js#L8)."},"comment":{"url":"https://api.github.com/repos/gridstack/gridstack.js/issues/comments/427743066","html_url":"https://github.com/gridstack/gridstack.js/issues/643#issuecomment-427743066","issue_url":"https://api.github.com/repos/gridstack/gridstack.js/issues/643","id":427743066,"node_id":"MDEyOklzc3VlQ29tbWVudDQyNzc0MzA2Ng==","user":{"login":"jaapz","id":513050,"node_id":"MDQ6VXNlcjUxMzA1MA==","avatar_url":"https://avatars0.githubusercontent.com/u/513050?v=4","gravatar_id":"","url":"https://api.github.com/users/jaapz","html_url":"https://github.com/jaapz","followers_url":"https://api.github.com/users/jaapz/followers","following_url":"https://api.github.com/users/jaapz/following{/other_user}","gists_url":"https://api.github.com/users/jaapz/gists{/gist_id}","starred_url":"https://api.github.com/users/jaapz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jaapz/subscriptions","organizations_url":"https://api.github.com/users/jaapz/orgs","repos_url":"https://api.github.com/users/jaapz/repos","events_url":"https://api.github.com/users/jaapz/events{/privacy}","received_events_url":"https://api.github.com/users/jaapz/received_events","type":"User","site_admin":false},"created_at":"2018-10-08T07:31:36Z","updated_at":"2018-10-08T07:31:36Z","author_association":"NONE","body":"So, during a run of dependency upgrades (bootstrap 3 -> 4, jquery to latest version, you know the drill) I  came across this issue and decided that after more than a year my \"later today\" has finally come ;)\r\n\r\nI fixed the issue on the latest version of develop and opened a pull request. I'm currently using that fixed repository in our browserify build which seems to work fine.\r\n\r\nWould be great to get this in a release so we can finally close this!\r\n\r\n@rpionke for now you can use our repo at AdvancedClimateSystems/gridstack.js as it has the fix which correctly exports gridstack for commonjs and requirejs."}}
{"actor":{"display_login":"jaapz"}}