{"action":"created","issue":{"url":"https://api.github.com/repos/BabylonJS/Babylon.js/issues/539","labels_url":"https://api.github.com/repos/BabylonJS/Babylon.js/issues/539/labels{/name}","comments_url":"https://api.github.com/repos/BabylonJS/Babylon.js/issues/539/comments","events_url":"https://api.github.com/repos/BabylonJS/Babylon.js/issues/539/events","html_url":"https://github.com/BabylonJS/Babylon.js/issues/539","id":83265454,"number":539,"title":"Latest npm package is not node friendly, not isomorphic, breaks Browserify/Webpack workflow. ","user":{"login":"kevzettler","id":126209,"avatar_url":"https://avatars.githubusercontent.com/u/126209?v=3","gravatar_id":"","url":"https://api.github.com/users/kevzettler","html_url":"https://github.com/kevzettler","followers_url":"https://api.github.com/users/kevzettler/followers","following_url":"https://api.github.com/users/kevzettler/following{/other_user}","gists_url":"https://api.github.com/users/kevzettler/gists{/gist_id}","starred_url":"https://api.github.com/users/kevzettler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kevzettler/subscriptions","organizations_url":"https://api.github.com/users/kevzettler/orgs","repos_url":"https://api.github.com/users/kevzettler/repos","events_url":"https://api.github.com/users/kevzettler/events{/privacy}","received_events_url":"https://api.github.com/users/kevzettler/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/BabylonJS/Babylon.js/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":{"login":"deltakosh","id":1306056,"avatar_url":"https://avatars.githubusercontent.com/u/1306056?v=3","gravatar_id":"","url":"https://api.github.com/users/deltakosh","html_url":"https://github.com/deltakosh","followers_url":"https://api.github.com/users/deltakosh/followers","following_url":"https://api.github.com/users/deltakosh/following{/other_user}","gists_url":"https://api.github.com/users/deltakosh/gists{/gist_id}","starred_url":"https://api.github.com/users/deltakosh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/deltakosh/subscriptions","organizations_url":"https://api.github.com/users/deltakosh/orgs","repos_url":"https://api.github.com/users/deltakosh/repos","events_url":"https://api.github.com/users/deltakosh/events{/privacy}","received_events_url":"https://api.github.com/users/deltakosh/received_events","type":"User","site_admin":false},"milestone":null,"comments":21,"created_at":"2015-06-01T02:03:34Z","updated_at":"2015-06-08T22:11:33Z","closed_at":null,"body":"I upgraded my npm babylon dependency to the latest `2.0.2` and my project no longer works. I have been using the old `1.13.3` npm module with success and I can downgrade to that version and things still work.\r\n\r\nI'm using webpack to require babylon in a browser environment. In the browser i'm now seeing this error\r\n`Uncaught TypeError: Cannot read property 'prototype' of undefined`\r\n\r\nWhich is coming from some minified babylon code that looks like:\r\n```javascript\r\n        var __extends = this.__extends || function(t, e) {\r\n            function i() {\r\n                this.constructor = t\r\n            }\r\n            for (var r in e)\r\n                e.hasOwnProperty(r) && (t[r] = e[r]);\r\n            i.prototype = e.prototype, t.prototype = new i  ///******* THIS LINE IS THROWING ERROR****\r\n```\r\n\r\nListed below is some output that shows problems when trying to require the babylonjs module directly form a node server side repl.\r\n\r\n\r\n```shell\r\nkevs-mbp:web kevzettler$ npm install babylonjs\r\nkevs-mbp:web kevzettler$ npm ls babylonjs\r\nrougeland-server@0.0.0 /Users/kevzettler/plebland/web\r\n├── babylonjs@2.0.2\r\n```\r\nOk we have 2.0.2 installed\r\n\r\n```shell\r\n^Ckevs-mbp:web kevzettler$ node\r\n> var BABYLON = require('babylonjs');\r\nReferenceError: window is not defined\r\n    at BABYLON (/dist/node_modules/babylonjs/babylon.js:3:24377)\r\n    at Object.<anonymous> (/dist/node_modules/babylonjs/babylon.js:3:24459)\r\n    at Module._compile (module.js:456:26)\r\n    at Object.Module._extensions..js (module.js:474:10)\r\n    at Module.load (module.js:356:32)\r\n    at Function.Module._load (module.js:312:12)\r\n    at Module.require (module.js:364:17)\r\n    at require (module.js:380:17)\r\n    at repl:1:15\r\n    at REPLServer.self.eval (repl.js:110:21)\r\n```\r\n\r\nJust requiring it initially throws an error because there is no `window` object.\r\nIts usually bad practice to publish code to npm that expects a `window`. \r\nIts okay though we can spoof it right?\r\n\r\n```shell\r\n> var window = {};\r\nundefined\r\n> var BABYLON = require('babylonjs');\r\nReferenceError: navigator is not defined\r\n    at Function.r.GetPointerPrefix (/dist/node_modules/babylonjs/babylon.js:5:10268)\r\n    at BABYLON (/dist/node_modules/babylonjs/babylon.js:10:27190)\r\n    at Object.<anonymous> (/dist/node_modules/babylonjs/babylon.js:11:5056)\r\n    at Module._compile (module.js:456:26)\r\n    at Object.Module._extensions..js (module.js:474:10)\r\n    at Module.load (module.js:356:32)\r\n    at Function.Module._load (module.js:312:12)\r\n    at Module.require (module.js:364:17)\r\n    at require (module.js:380:17)\r\n    at repl:1:15\r\n```\r\n\r\nSame issue with the `navigator` object. This issues exists in the `1.13.3` I was already working around it.\r\nWe can spoof it like window.\r\n\r\n\r\n```\r\n> var navigator = {};\r\nundefined\r\n> var BABYLON = require('babylonjs');\r\nTypeError: Cannot read property 'prototype' of undefined\r\n    at __extends (/dist/node_modules/babylonjs/babylon.js:20:25655)\r\n    at /dist/node_modules/babylonjs/babylon.js:20:26207\r\n    at BABYLON (/dist/node_modules/babylonjs/babylon.js:20:26224)\r\n    at Object.<anonymous> (/dist/node_modules/babylonjs/babylon.js:20:26268)\r\n    at Module._compile (module.js:456:26)\r\n    at Object.Module._extensions..js (module.js:474:10)\r\n    at Module.load (module.js:356:32)\r\n    at Function.Module._load (module.js:312:12)\r\n    at Module.require (module.js:364:17)\r\n    at require (module.js:380:17)\r\n```\r\n\r\nOk so now it breaks by just requiring the module. Is it possible spoofing `window` and `navigator` broke it? Hard to tell because the code is minified. \r\n\r\nFirstly I think there should be better error capturing in this library. I've hit vague errors several times now that don't give any indication of whats breaking. Secondly I feel that the minified code should not be published to npm. "},"comment":{"url":"https://api.github.com/repos/BabylonJS/Babylon.js/issues/comments/110158973","html_url":"https://github.com/BabylonJS/Babylon.js/issues/539#issuecomment-110158973","issue_url":"https://api.github.com/repos/BabylonJS/Babylon.js/issues/539","id":110158973,"user":{"login":"deltakosh","id":1306056,"avatar_url":"https://avatars.githubusercontent.com/u/1306056?v=3","gravatar_id":"","url":"https://api.github.com/users/deltakosh","html_url":"https://github.com/deltakosh","followers_url":"https://api.github.com/users/deltakosh/followers","following_url":"https://api.github.com/users/deltakosh/following{/other_user}","gists_url":"https://api.github.com/users/deltakosh/gists{/gist_id}","starred_url":"https://api.github.com/users/deltakosh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/deltakosh/subscriptions","organizations_url":"https://api.github.com/users/deltakosh/orgs","repos_url":"https://api.github.com/users/deltakosh/repos","events_url":"https://api.github.com/users/deltakosh/events{/privacy}","received_events_url":"https://api.github.com/users/deltakosh/received_events","type":"User","site_admin":false},"created_at":"2015-06-08T22:11:33Z","updated_at":"2015-06-08T22:11:33Z","body":"Should be goooooood now :)"}}