{"action":"created","issue":{"url":"https://api.github.com/repos/redfin/react-server/issues/896","repository_url":"https://api.github.com/repos/redfin/react-server","labels_url":"https://api.github.com/repos/redfin/react-server/issues/896/labels{/name}","comments_url":"https://api.github.com/repos/redfin/react-server/issues/896/comments","events_url":"https://api.github.com/repos/redfin/react-server/issues/896/events","html_url":"https://github.com/redfin/react-server/issues/896","id":213993542,"number":896,"title":"Support ignoring given route when building client bundle files","user":{"login":"mocheng","id":239291,"avatar_url":"https://avatars2.githubusercontent.com/u/239291?v=3","gravatar_id":"","url":"https://api.github.com/users/mocheng","html_url":"https://github.com/mocheng","followers_url":"https://api.github.com/users/mocheng/followers","following_url":"https://api.github.com/users/mocheng/following{/other_user}","gists_url":"https://api.github.com/users/mocheng/gists{/gist_id}","starred_url":"https://api.github.com/users/mocheng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mocheng/subscriptions","organizations_url":"https://api.github.com/users/mocheng/orgs","repos_url":"https://api.github.com/users/mocheng/repos","events_url":"https://api.github.com/users/mocheng/events{/privacy}","received_events_url":"https://api.github.com/users/mocheng/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-03-14T07:59:33Z","updated_at":"2017-03-21T11:16:57Z","closed_at":null,"body":"For the time being, `react-server-cli` builds client bundle file for each route, even for route with [JsonResposneMiddleware](https://github.com/redfin/react-server/tree/master/packages/react-server-middleware-json-response) that is actually not a web page. \r\n\r\nBesides the waste of building bundle js that is never used, this process introduce a severe problem to webpack `CommonsChunkPlugin`. In `react-server-cli`, the `CommonsChunkPlugin` is created [without `minChunks` option](https://github.com/redfin/react-server/blob/master/packages/react-server-cli/src/compileClient.js#L231-L233). As a result, it only extract modules that is referenced by all chunks.\r\n\r\nSuppose there are some common components that are shared in all web pages. The components code should be extract to `common.bundle.js`. However, when I add one API route that just returns JSON content, without any reference to those common components. `CommonsChunkPlugin` would takes those common components not so *common* and make each web page bundle file have their own copies. This makes web page bundle file bloated! This is real waste.\r\n\r\nEven though we can tweak [`minChunks`](https://webpack.github.io/docs/list-of-plugins.html#commonschunkplugin) by `webpackConifg` in file `.reactserverrc`, it would be more convenient to config it in `routes.json`.\r\n\r\nSuggest to have `noClientJs` config value in `routes.json`. For example, in below config, `Foo` route is just API. With `noClientJs: true`, there is not entry for this route is passed to webpack.\r\n```\r\n{\r\n  middleware: [],\r\n  routes: {\r\n    Home: {\r\n      path: \"/\",\r\n      method: \"get\",\r\n      page: \"./pages/Home\"\r\n    },\r\n    Foo: {\r\n      path: \"/api/foo\",\r\n      method: \"get\",\r\n      noClientJs: true,\r\n      page: \"./apis/Foo\"\r\n    }\r\n  }\r\n```\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/redfin/react-server/issues/comments/288048249","html_url":"https://github.com/redfin/react-server/issues/896#issuecomment-288048249","issue_url":"https://api.github.com/repos/redfin/react-server/issues/896","id":288048249,"user":{"login":"mocheng","id":239291,"avatar_url":"https://avatars2.githubusercontent.com/u/239291?v=3","gravatar_id":"","url":"https://api.github.com/users/mocheng","html_url":"https://github.com/mocheng","followers_url":"https://api.github.com/users/mocheng/followers","following_url":"https://api.github.com/users/mocheng/following{/other_user}","gists_url":"https://api.github.com/users/mocheng/gists{/gist_id}","starred_url":"https://api.github.com/users/mocheng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mocheng/subscriptions","organizations_url":"https://api.github.com/users/mocheng/orgs","repos_url":"https://api.github.com/users/mocheng/repos","events_url":"https://api.github.com/users/mocheng/events{/privacy}","received_events_url":"https://api.github.com/users/mocheng/received_events","type":"User","site_admin":false},"created_at":"2017-03-21T11:16:57Z","updated_at":"2017-03-21T11:16:57Z","body":"One more interesting side effect: If not all UI common modules go into `common.js`, so are css modules. As a result, on page navigation, page specific CSS files are switched, which makes page flickering."}}
{"actor":{"display_login":"mocheng"}}