{"action":"opened","issue":{"url":"https://api.github.com/repos/substack/node-browserify/issues/1346","labels_url":"https://api.github.com/repos/substack/node-browserify/issues/1346/labels{/name}","comments_url":"https://api.github.com/repos/substack/node-browserify/issues/1346/comments","events_url":"https://api.github.com/repos/substack/node-browserify/issues/1346/events","html_url":"https://github.com/substack/node-browserify/issues/1346","id":98705897,"number":1346,"title":"Automatic creation of multiple bundles","user":{"login":"bfred-it","id":1402241,"avatar_url":"https://avatars.githubusercontent.com/u/1402241?v=3","gravatar_id":"","url":"https://api.github.com/users/bfred-it","html_url":"https://github.com/bfred-it","followers_url":"https://api.github.com/users/bfred-it/followers","following_url":"https://api.github.com/users/bfred-it/following{/other_user}","gists_url":"https://api.github.com/users/bfred-it/gists{/gist_id}","starred_url":"https://api.github.com/users/bfred-it/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bfred-it/subscriptions","organizations_url":"https://api.github.com/users/bfred-it/orgs","repos_url":"https://api.github.com/users/bfred-it/repos","events_url":"https://api.github.com/users/bfred-it/events{/privacy}","received_events_url":"https://api.github.com/users/bfred-it/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-08-03T09:32:59Z","updated_at":"2015-08-03T09:32:59Z","closed_at":null,"body":"This is a feature request or a workflow question.\r\n\r\nI have a hyper modular application. Its entry point is currently a file that imports all the features:\r\n\r\n    require('./feature-a');\r\n    require('./feature-b');\r\n    require('./feature-c');\r\n\r\nI would like to know of a way to split this entry point into up to three bundles. **The motive here is performance:** make each feature be available as soon as possible.\r\n\r\n**Wrong solution 1:** I could simply create a bundle directly from each feature, but the problem is that they have shared dependencies; doing so would include the dependency in each file.\r\n\r\n**Wrong solution 2:** Create a bundle for each, plus a bundle with common dependencies (with `factor-bundle`) and load it first. This sort of works, but the scripts can't be loaded with `async` so if `common.js` is large, a smaller `feature-d` still has to wait for it to load, even if it doesn't depend on it.\r\n\r\n**Ideal solution:** create x bundles from the first file and make internal requires work like AMD. Instead of having a single, heavy `common.js`, the first 1-2 levels of dependencies are transformed into AMD requires and bundled into smart bundles:\r\n\r\ne.g. if only `feature-b` requires `jquery` and `lodash`, make a single bundle with all the three.\r\ne.g. if `feature-a` and `feature-c` require 'kew' and `raf`, either bundle them together, or create a `a-c-common.js` file.\r\n\r\n---\r\n\r\nI know this sounds complex, but maybe someone already came up with a better solution. For now I've only manually create 2-4 bundles that have 0 shared dependencies (or they do… and load them multiple times)"}}