{"action":"created","issue":{"url":"https://api.github.com/repos/webpack/webpack/issues/2866","repository_url":"https://api.github.com/repos/webpack/webpack","labels_url":"https://api.github.com/repos/webpack/webpack/issues/2866/labels{/name}","comments_url":"https://api.github.com/repos/webpack/webpack/issues/2866/comments","events_url":"https://api.github.com/repos/webpack/webpack/issues/2866/events","html_url":"https://github.com/webpack/webpack/issues/2866","id":170988965,"number":2866,"title":"[webpack2] Tree shaking and \"unused harmony default export\"","user":{"login":"tleunen","id":1972567,"avatar_url":"https://avatars.githubusercontent.com/u/1972567?v=3","gravatar_id":"","url":"https://api.github.com/users/tleunen","html_url":"https://github.com/tleunen","followers_url":"https://api.github.com/users/tleunen/followers","following_url":"https://api.github.com/users/tleunen/following{/other_user}","gists_url":"https://api.github.com/users/tleunen/gists{/gist_id}","starred_url":"https://api.github.com/users/tleunen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tleunen/subscriptions","organizations_url":"https://api.github.com/users/tleunen/orgs","repos_url":"https://api.github.com/users/tleunen/repos","events_url":"https://api.github.com/users/tleunen/events{/privacy}","received_events_url":"https://api.github.com/users/tleunen/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/webpack/webpack/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/webpack/webpack/labels/P2:%20Required","name":"P2: Required","color":"d93f0b"},{"url":"https://api.github.com/repos/webpack/webpack/labels/S4:%20Broken","name":"S4: Broken","color":"0052cc"},{"url":"https://api.github.com/repos/webpack/webpack/labels/webpack-2","name":"webpack-2","color":"c5def5"},{"url":"https://api.github.com/repos/webpack/webpack/labels/X0:%20need%20more%20information","name":"X0: need more information","color":"d4c5f9"}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-08-13T02:39:11Z","updated_at":"2016-09-08T08:37:00Z","closed_at":"2016-09-08T08:37:00Z","body":"I'm running webpack 2 beta 20 and for a development build, I can see a lot of `unused harmony default export` in my UI library (which is normal since I don't use everything that is available in the library).\r\n\r\nI checked the code and instead of exporting the class with the webpack require function, i see this, which seems ok.\r\n```js\r\n/* unused harmony default export */ var _unused_webpack_default_export = ComponentA;\r\n```\r\n\r\nBut when I build the app in a production environment, the component is still there, even if it has been marked as unused.\r\n\r\nThe component is imported and exported from another file before my app really uses it.\r\n```js\r\nexport { default as ComponentA } from './ComponentA';\r\n```\r\nand inside that file, it's marked like this:\r\n```js\r\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_19__ComponentA__ = __webpack_require__(622);\r\n/* unused harmony reexport ComponentA */\r\n```\r\n\r\nI also checked the compiled code in production, and the code is there but as it's mentioned with the unused reexport, nothing is exported... No `t.default = ...`\r\n\r\nFrom what I see, it seems there's an issue in the tree-shaking/code elimination. Can you confirm, or tell me what would be wrong in what I'm trying to do?"},"comment":{"url":"https://api.github.com/repos/webpack/webpack/issues/comments/245530852","html_url":"https://github.com/webpack/webpack/issues/2866#issuecomment-245530852","issue_url":"https://api.github.com/repos/webpack/webpack/issues/2866","id":245530852,"user":{"login":"sokra","id":1365881,"avatar_url":"https://avatars.githubusercontent.com/u/1365881?v=3","gravatar_id":"","url":"https://api.github.com/users/sokra","html_url":"https://github.com/sokra","followers_url":"https://api.github.com/users/sokra/followers","following_url":"https://api.github.com/users/sokra/following{/other_user}","gists_url":"https://api.github.com/users/sokra/gists{/gist_id}","starred_url":"https://api.github.com/users/sokra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sokra/subscriptions","organizations_url":"https://api.github.com/users/sokra/orgs","repos_url":"https://api.github.com/users/sokra/repos","events_url":"https://api.github.com/users/sokra/events{/privacy}","received_events_url":"https://api.github.com/users/sokra/received_events","type":"User","site_admin":false},"created_at":"2016-09-08T08:36:58Z","updated_at":"2016-09-08T08:36:58Z","body":"Looks correct to me. The functions itself are removed by UglifyJs once you minimize the file.\r\n\r\nMinimized file:\r\n\r\n``` js\r\n!function(t){function n(e){if(r[e])return r[e].exports\r\nvar u=r[e]={i:e,l:!1,exports:{}}\r\nreturn t[e].call(u.exports,u,u.exports,n),u.l=!0,u.exports}var r={}\r\nreturn n.m=t,n.c=r,n.i=function(t){return t},n.d=function(t,n,r){Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:r})},n.n=function(t){var r=t&&t.__esModule?function(){return t[\"default\"]}:function(){return t}\r\nreturn n.d(r,\"a\",r),r},n.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},n.p=\"/\",n(n.s=4)}([function(t,n,r){\"use strict\"\r\nvar e=(r(1),r(2),r(3))\r\nr.d(n,\"a\",function(){return e.a})},function(t,n,r){\"use strict\"},function(t,n,r){\"use strict\"},function(t,n,r){\"use strict\"\r\nfunction e(){console.log(\"util 3.1\")}n.a=e},function(t,n,r){\"use strict\"\r\nvar e=r(0)\r\nr.i(e.a)()}])\r\n```\r\n\r\nThe minimized file only contains `console.log(\"util 3.1\")`."}}
{"actor":{"display_login":"sokra"}}