{"action":"created","issue":{"url":"https://api.github.com/repos/systemjs/builder/issues/723","repository_url":"https://api.github.com/repos/systemjs/builder","labels_url":"https://api.github.com/repos/systemjs/builder/issues/723/labels{/name}","comments_url":"https://api.github.com/repos/systemjs/builder/issues/723/comments","events_url":"https://api.github.com/repos/systemjs/builder/issues/723/events","html_url":"https://github.com/systemjs/builder/issues/723","id":184058715,"number":723,"title":"angular 2 lazy modules can't find exports","user":{"login":"mikesnare","id":1864022,"avatar_url":"https://avatars.githubusercontent.com/u/1864022?v=3","gravatar_id":"","url":"https://api.github.com/users/mikesnare","html_url":"https://github.com/mikesnare","followers_url":"https://api.github.com/users/mikesnare/followers","following_url":"https://api.github.com/users/mikesnare/following{/other_user}","gists_url":"https://api.github.com/users/mikesnare/gists{/gist_id}","starred_url":"https://api.github.com/users/mikesnare/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mikesnare/subscriptions","organizations_url":"https://api.github.com/users/mikesnare/orgs","repos_url":"https://api.github.com/users/mikesnare/repos","events_url":"https://api.github.com/users/mikesnare/events{/privacy}","received_events_url":"https://api.github.com/users/mikesnare/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-10-19T19:56:48Z","updated_at":"2016-10-20T10:21:11Z","closed_at":null,"body":"Not sure if this is the right place for this or not -- apologies if not.\r\n\r\nWe're using the builder to create a single file out of our entire angular 2 app, and that works fine.  I'm investigating using lazy modules to break up the app and reduce load times, but no matter what I try I can't make it work.\r\n\r\nI know how to get the sub modules built into separate bundles.  I know how to get the angular app to load those modules on demand, but I cannot get angular to find either the default export from the included module or a named export.\r\n\r\nThese are all TS classes, typically with one export per file.  Per the angular docs for lazy modules, I have changed the module file for the lazy module to use a default export but then when angular loads it it says it cannot find the default value for the module.  (I've also tried using a `bundle.js#ModuleName` url for the lazy module and angular just says the module doesn't have a `ModuleName`).\r\n\r\nI *think* my problem is that the bundles created by the builder do not have an exported value.  Is there a way to create a bundle with an exported value?"},"comment":{"url":"https://api.github.com/repos/systemjs/builder/issues/comments/255067703","html_url":"https://github.com/systemjs/builder/issues/723#issuecomment-255067703","issue_url":"https://api.github.com/repos/systemjs/builder/issues/723","id":255067703,"user":{"login":"guybedford","id":598730,"avatar_url":"https://avatars.githubusercontent.com/u/598730?v=3","gravatar_id":"","url":"https://api.github.com/users/guybedford","html_url":"https://github.com/guybedford","followers_url":"https://api.github.com/users/guybedford/followers","following_url":"https://api.github.com/users/guybedford/following{/other_user}","gists_url":"https://api.github.com/users/guybedford/gists{/gist_id}","starred_url":"https://api.github.com/users/guybedford/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guybedford/subscriptions","organizations_url":"https://api.github.com/users/guybedford/orgs","repos_url":"https://api.github.com/users/guybedford/repos","events_url":"https://api.github.com/users/guybedford/events{/privacy}","received_events_url":"https://api.github.com/users/guybedford/received_events","type":"User","site_admin":false},"created_at":"2016-10-20T10:21:11Z","updated_at":"2016-10-20T10:21:11Z","body":"Make sure you are using the `bundle` feature of the builder and not `buildStatic` or `build`. Exports should definitely be coming through fine - if you're getting no exports it may be beacuse you've loaded the bundle itself - note that the bundle does not have a value.\r\n\r\nThat is:\r\n\r\n```javascript\r\nSystem.import('bundle.js').then(function(m) {\r\n  console.log(m);\r\n});\r\n```\r\n\r\nWill give you an empty module with no exports. That is because the bundle itself has no exports, but it defines other modules.\r\n\r\nSo the correct way to do this is:\r\n\r\n```javascript\r\nSystem.import('bundle.js').then(function() {\r\n  System.import('file-from-bundle.js').then(function(m) {\r\n    console.log(m);\r\n  });\r\n});\r\n```\r\n\r\nThe second System.import then needs to be named exactly right to get the defined value from the bundle.\r\n\r\nThe above code can then be simplified with bundles configuration:\r\n\r\n```javascript\r\nSystem.config({\r\n  bundles: {\r\n    'bundle.js': ['file-from-bundle.js']\r\n  }\r\n});\r\nSystem.import('file-from-bundle.js'); // this is now equivalent to the above double import\r\n```"}}
{"actor":{"display_login":"guybedford"}}