{"action":"created","issue":{"url":"https://api.github.com/repos/webpack/webpack/issues/6647","repository_url":"https://api.github.com/repos/webpack/webpack","labels_url":"https://api.github.com/repos/webpack/webpack/issues/6647/labels{/name}","comments_url":"https://api.github.com/repos/webpack/webpack/issues/6647/comments","events_url":"https://api.github.com/repos/webpack/webpack/issues/6647/events","html_url":"https://github.com/webpack/webpack/issues/6647","id":301619844,"number":6647,"title":"Webpack 4 chunking different runtime behaviour compared to Webpack 3","user":{"login":"garygreen","id":1702638,"avatar_url":"https://avatars2.githubusercontent.com/u/1702638?v=4","gravatar_id":"","url":"https://api.github.com/users/garygreen","html_url":"https://github.com/garygreen","followers_url":"https://api.github.com/users/garygreen/followers","following_url":"https://api.github.com/users/garygreen/following{/other_user}","gists_url":"https://api.github.com/users/garygreen/gists{/gist_id}","starred_url":"https://api.github.com/users/garygreen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/garygreen/subscriptions","organizations_url":"https://api.github.com/users/garygreen/orgs","repos_url":"https://api.github.com/users/garygreen/repos","events_url":"https://api.github.com/users/garygreen/events{/privacy}","received_events_url":"https://api.github.com/users/garygreen/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-03-02T01:20:23Z","updated_at":"2018-03-02T12:24:54Z","closed_at":null,"author_association":"NONE","body":"**Do you want to request a *feature* or report a *bug*?**\r\n\r\nBug / Change in behaviour compared to Webpack 3\r\n\r\n**What is the current behavior?**\r\n\r\nWhen telling Webpack which chunk the runtime should be in (via `runtimeChunk.name`), it doesn't appear to change the order of execution - see below example.\r\n\r\n**If the current behavior is a bug, please provide the steps to reproduce.**\r\n\r\n### vendor.js\r\n```js\r\nimport $ from 'jquery';\r\nconsole.log('vendor run.');\r\n$.fn.sayHi = function() {\r\n    alert('Hi');\r\n};\r\n```\r\n\r\n### main.js\r\n```js\r\nimport $ from 'jquery';\r\nconsole.log('main run.');\r\n$.fn.sayHi();\r\n```\r\n\r\n### index.htm\r\n```htm\r\n<html>\r\n<body>\r\n<script src=\"dist/vendor.js\"></script>\r\n<script src=\"dist/main.js\"></script>\r\n</body>\r\n</html>\r\n```\r\n\r\n### Webpack 3 config\r\n```js\r\nvar webpack = require('webpack');\r\nvar path = require('path');\r\n\r\nmodule.exports = {\r\n\r\n    mode: 'production',\r\n\r\n    entry: {\r\n        main: './main.js',\r\n        vendor: './vendor.js'\r\n    },\r\n\r\n    output: {\r\n        path: path.resolve(__dirname, './dist'),\r\n        filename: '[name].js',\r\n    },\r\n\r\n    optimization: {\r\n        minimize: false,\r\n        runtimeChunk: {\r\n            name: 'vendor'\r\n        },\r\n        splitChunks: {\r\n            cacheGroups: {\r\n                default: false,\r\n                commons: {\r\n                    test: /node_modules/,\r\n                    name: \"vendor\",\r\n                    chunks: \"initial\",\r\n                    minSize: 1\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n};\r\n```\r\n\r\n### Webpack 4 Result\r\n\r\n![image](https://user-images.githubusercontent.com/1702638/36878612-b34a8f90-1db7-11e8-8267-4de7ac8b68bd.png)\r\n\r\n![image](https://user-images.githubusercontent.com/1702638/36878462-054e3de2-1db7-11e8-904b-257e69c57938.png)\r\n\r\nAs you can see, `main run` fires before vendor, even though the runtime has been put inside vendor and it's loaded first.\r\n\r\n## Webpack 3 Result\r\n\r\n![image](https://user-images.githubusercontent.com/1702638/36878731-425e80e2-1db8-11e8-889b-6cb444cad8fe.png)\r\n\r\n![image](https://user-images.githubusercontent.com/1702638/36878543-6657b262-1db7-11e8-951c-55b2b735172a.png)\r\n\r\nAs you can see `vendor run` fires first, which means plugin is successfully registered and the alert dialog pops up."},"comment":{"url":"https://api.github.com/repos/webpack/webpack/issues/comments/369907662","html_url":"https://github.com/webpack/webpack/issues/6647#issuecomment-369907662","issue_url":"https://api.github.com/repos/webpack/webpack/issues/6647","id":369907662,"user":{"login":"garygreen","id":1702638,"avatar_url":"https://avatars2.githubusercontent.com/u/1702638?v=4","gravatar_id":"","url":"https://api.github.com/users/garygreen","html_url":"https://github.com/garygreen","followers_url":"https://api.github.com/users/garygreen/followers","following_url":"https://api.github.com/users/garygreen/following{/other_user}","gists_url":"https://api.github.com/users/garygreen/gists{/gist_id}","starred_url":"https://api.github.com/users/garygreen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/garygreen/subscriptions","organizations_url":"https://api.github.com/users/garygreen/orgs","repos_url":"https://api.github.com/users/garygreen/repos","events_url":"https://api.github.com/users/garygreen/events{/privacy}","received_events_url":"https://api.github.com/users/garygreen/received_events","type":"User","site_admin":false},"created_at":"2018-03-02T12:24:54Z","updated_at":"2018-03-02T12:24:54Z","author_association":"NONE","body":"@sokra Thanks that works nicely. I think I was using my old Webpack 3 config in a slightly weird way so it didn't really translate to Webpack 4 too well.\r\n\r\nOut of interest, would you be able to explain what the `enforce` option does? Does that just turn off any additional checks/conditions so if it matches the `test` case it always splits it?\r\n\r\nAlso I don't quite understand the `chunks` option - for instance, what's it mean by `initial`? It that basically any non `async` stuff?"}}
{"actor":{"display_login":"garygreen"}}