{"action":"created","issue":{"url":"https://api.github.com/repos/almende/vis/issues/2163","repository_url":"https://api.github.com/repos/almende/vis","labels_url":"https://api.github.com/repos/almende/vis/issues/2163/labels{/name}","comments_url":"https://api.github.com/repos/almende/vis/issues/2163/comments","events_url":"https://api.github.com/repos/almende/vis/issues/2163/events","html_url":"https://github.com/almende/vis/issues/2163","id":183494531,"number":2163,"title":"Build creates wrong code for moment.js embed","user":{"login":"neolivz","id":754818,"avatar_url":"https://avatars.githubusercontent.com/u/754818?v=3","gravatar_id":"","url":"https://api.github.com/users/neolivz","html_url":"https://github.com/neolivz","followers_url":"https://api.github.com/users/neolivz/followers","following_url":"https://api.github.com/users/neolivz/following{/other_user}","gists_url":"https://api.github.com/users/neolivz/gists{/gist_id}","starred_url":"https://api.github.com/users/neolivz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/neolivz/subscriptions","organizations_url":"https://api.github.com/users/neolivz/orgs","repos_url":"https://api.github.com/users/neolivz/repos","events_url":"https://api.github.com/users/neolivz/events{/privacy}","received_events_url":"https://api.github.com/users/neolivz/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/almende/vis/labels/question","name":"question","color":"cc317c"}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-10-17T18:43:01Z","updated_at":"2016-10-17T19:28:30Z","closed_at":"2016-10-17T19:28:30Z","body":"When web pack build is happening it is creating \r\n```\r\n                  !(function webpackMissingModule() { var e = new Error(\"Cannot find module \\\"./locale\\\"\"); e.code = 'MODULE_NOT_FOUND'; throw e; }());\r\n```\r\nthis is due to the build process is repeatdly going through each of the require and embeddin it into the vis.js file. This is fine as long full require is present but in moment.js|\r\n\r\n```\r\nfunction loadLocale(name) {\r\n        var oldLocale = null;\r\n        // TODO: Find a better way to register and load all the locales in Node\r\n        if (!locales[name] && (typeof module !== 'undefined') &&\r\n                module && module.exports) {\r\n            try {\r\n                oldLocale = globalLocale._abbr;\r\n                require('./locale/' + name);\r\n                // because defineLocale currently also sets the global locale, we\r\n                // want to undo that for lazy loaded locales\r\n                locale_locales__getSetGlobalLocale(oldLocale);\r\n            } catch (e) { }\r\n        }\r\n        return locales[name];\r\n    }\r\n```\r\nwhich causes build to create wrong output."},"comment":{"url":"https://api.github.com/repos/almende/vis/issues/comments/254308117","html_url":"https://github.com/almende/vis/issues/2163#issuecomment-254308117","issue_url":"https://api.github.com/repos/almende/vis/issues/2163","id":254308117,"user":{"login":"mojoaxel","id":600565,"avatar_url":"https://avatars.githubusercontent.com/u/600565?v=3","gravatar_id":"","url":"https://api.github.com/users/mojoaxel","html_url":"https://github.com/mojoaxel","followers_url":"https://api.github.com/users/mojoaxel/followers","following_url":"https://api.github.com/users/mojoaxel/following{/other_user}","gists_url":"https://api.github.com/users/mojoaxel/gists{/gist_id}","starred_url":"https://api.github.com/users/mojoaxel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mojoaxel/subscriptions","organizations_url":"https://api.github.com/users/mojoaxel/orgs","repos_url":"https://api.github.com/users/mojoaxel/repos","events_url":"https://api.github.com/users/mojoaxel/events{/privacy}","received_events_url":"https://api.github.com/users/mojoaxel/received_events","type":"User","site_admin":false},"created_at":"2016-10-17T19:28:30Z","updated_at":"2016-10-17T19:28:30Z","body":"There are multiple things to note using vis with webpack:\r\n\r\n1) You should always importing only the vis modules that you use in your application and not the big \"all-inclusive\" distribution-version.\r\n\r\n2) Vis.js is written in ES2015. You need to setup babel for this:\r\n```\r\n{ test: /node_modules[\\\\\\/]vis[\\\\\\/].*\\.js$/, loader: 'babel',\r\n\tquery: {\r\n\t\tcacheDirectory: true,\r\n\t\tpresets: [\"es2015\"]\r\n\t}\r\n},\r\n```\r\n\r\n3) There is a problem importing moment.js with webpack. [See here](http://stackoverflow.com/questions/25384360/how-to-prevent-moment-js-from-loading-locales-with-webpack). You could fix this by using webpacks \"ContextReplacementPlugin\":\r\n```\r\nnew webpack.ContextReplacementPlugin(/moment[\\\\\\/]locale$/, /^\\.\\/(de|en)$/),\r\n```"}}
{"actor":{"display_login":"mojoaxel"}}