{"action":"created","issue":{"url":"https://api.github.com/repos/webpack/webpack/issues/660","labels_url":"https://api.github.com/repos/webpack/webpack/issues/660/labels{/name}","comments_url":"https://api.github.com/repos/webpack/webpack/issues/660/comments","events_url":"https://api.github.com/repos/webpack/webpack/issues/660/events","html_url":"https://github.com/webpack/webpack/issues/660","id":53385892,"number":660,"title":"When using CommonsChunkPlugin, the common bundle built contains hash list of all entry points","user":{"login":"happypoulp","id":100044,"avatar_url":"https://avatars.githubusercontent.com/u/100044?v=3","gravatar_id":"","url":"https://api.github.com/users/happypoulp","html_url":"https://github.com/happypoulp","followers_url":"https://api.github.com/users/happypoulp/followers","following_url":"https://api.github.com/users/happypoulp/following{/other_user}","gists_url":"https://api.github.com/users/happypoulp/gists{/gist_id}","starred_url":"https://api.github.com/users/happypoulp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/happypoulp/subscriptions","organizations_url":"https://api.github.com/users/happypoulp/orgs","repos_url":"https://api.github.com/users/happypoulp/repos","events_url":"https://api.github.com/users/happypoulp/events{/privacy}","received_events_url":"https://api.github.com/users/happypoulp/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-01-05T11:11:58Z","updated_at":"2015-12-10T08:39:17Z","closed_at":"2015-01-05T18:00:27Z","body":"Hi,\r\n\r\nFirst of all, thanks for the awesomeness that webpack is. I've been using it for few weeks only but I found that it provides all I expect from a bundler (and that I did not found anywhere else).\r\n\r\nThe current issue is the only thing that is currently preventing me from using it on production.\r\n\r\nHere is the context:\r\n\r\nI intend to use webpack for a big existing website to replace the current old-school bundle solution. This website is not a webapp and it is updated several times a day.\r\n\r\nOur current bundle solution is built on a configuration file listing all bundles and the files they should embed. This allow us to have full control over what goes in a bundle and to maintain a common bundle for all pages. Then, each page is loaded with the common bundle and a page-specific bundle.\r\n\r\nI tried to achieve the same with webpack and I used this configuration file:\r\n\r\n```javascript\r\nvar webpack = require('webpack'),\r\n    path = require('path');\r\n\r\nvar configuration =\r\n    {\r\n        entry:\r\n        {\r\n            page1: './js/page1.js',\r\n            page2: './js/page2.js',\r\n            page3: './js/page3.js',\r\n        },\r\n        output:\r\n        {\r\n            path: 'build',\r\n            publicPath: 'build/',\r\n            filename: '[name].[chunkhash].js',\r\n            chunkFilename: '[id].[chunkhash].js'\r\n        },\r\n        plugins: [\r\n            new webpack.NewWatchingPlugin(),\r\n            new webpack.optimize.CommonsChunkPlugin('common.[chunkhash].js'),\r\n            function()\r\n            {\r\n                this.plugin(\"done\", function(stats)\r\n                {\r\n                    require(\"fs\").writeFileSync(\r\n                        path.join(__dirname, 'webpack_files_map.conf.json'),\r\n                        JSON.stringify(stats.toJson().assetsByChunkName)\r\n                    );\r\n                });\r\n            }\r\n        ],\r\n        resolve:\r\n        {\r\n            root: path.join(__dirname, 'js')\r\n        }\r\n    };\r\n\r\nmodule.exports = configuration;\r\n```\r\n\r\nThis configuration file produce correctly one bundle per page and a common bundle.\r\n\r\nThe behavior that is bothering me is that the common bundle embed the hash for all entry points:\r\n\r\n```javascript\r\n/******/ \t__webpack_require__.e = function requireEnsure(chunkId, callback) {\r\n...\r\n/******/ \t\t\tscript.src = __webpack_require__.p + \"\" + chunkId + \".\" + {\"0\":\"ec91e42ab36483e18cd9\",\"1\":\"73705fff499a2fecdeeb\",\"2\":\"5d017c0e038c150db29b\"}[chunkId] + \".js\";\r\n```\r\n\r\nThis line of the common bundle make the common bundle implicitly dependent of ALL others bundles. So a modification of a file in page1.js that is not present in the common bundle will surely invalidate the common bundle because of the hash of page1.js that is written in the common bundle.\r\n\r\nThis may seems like a detail but the true purpose of a common bundle is to have a bundle that is long-cached and that do not change too often. But making this common bundle dependent of all others bundle kind of ruin this long-term strategy.\r\n\r\nWhat I'd like is a way to specify this hashes externally (through a global var exposed in window) so that the common bundle is not dependent of others bundle addition / modification / deletion.\r\n\r\nThe code above could then become:\r\n\r\n```javascript\r\n/******/ \t__webpack_require__.e = function requireEnsure(chunkId, callback) {\r\n...\r\n/******/ \t\t\tscript.src = __webpack_require__.p + \"\" + chunkId + \".\" + WEBPACK_BUNDLE_HASHES + [chunkId] + \".js\";\r\n```\r\n\r\nThe WEBPACK_BUNDLE_HASHES content could be extracted from the JSON stats file that is produced at the end of the compilation phase (I am not sure if this is already possible).\r\n\r\nDo you think that this makes sense and that it could be done?\r\n\r\nThanks."},"comment":{"url":"https://api.github.com/repos/webpack/webpack/issues/comments/163534106","html_url":"https://github.com/webpack/webpack/issues/660#issuecomment-163534106","issue_url":"https://api.github.com/repos/webpack/webpack/issues/660","id":163534106,"user":{"login":"stephenkingsley","id":13380370,"avatar_url":"https://avatars.githubusercontent.com/u/13380370?v=3","gravatar_id":"","url":"https://api.github.com/users/stephenkingsley","html_url":"https://github.com/stephenkingsley","followers_url":"https://api.github.com/users/stephenkingsley/followers","following_url":"https://api.github.com/users/stephenkingsley/following{/other_user}","gists_url":"https://api.github.com/users/stephenkingsley/gists{/gist_id}","starred_url":"https://api.github.com/users/stephenkingsley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stephenkingsley/subscriptions","organizations_url":"https://api.github.com/users/stephenkingsley/orgs","repos_url":"https://api.github.com/users/stephenkingsley/repos","events_url":"https://api.github.com/users/stephenkingsley/events{/privacy}","received_events_url":"https://api.github.com/users/stephenkingsley/received_events","type":"User","site_admin":false},"created_at":"2015-12-10T08:39:17Z","updated_at":"2015-12-10T08:39:17Z","body":"@sokra if i don't to wrote the inline.js tag in html. Have some solution?"}}