{"action":"created","issue":{"url":"https://api.github.com/repos/angular/sickle/issues/47","repository_url":"https://api.github.com/repos/angular/sickle","labels_url":"https://api.github.com/repos/angular/sickle/issues/47/labels{/name}","comments_url":"https://api.github.com/repos/angular/sickle/issues/47/comments","events_url":"https://api.github.com/repos/angular/sickle/issues/47/events","html_url":"https://github.com/angular/sickle/issues/47","id":131209571,"number":47,"title":"De-reference all properties in `export * from ...`","user":{"login":"mprobst","id":7208,"avatar_url":"https://avatars.githubusercontent.com/u/7208?v=3","gravatar_id":"","url":"https://api.github.com/users/mprobst","html_url":"https://github.com/mprobst","followers_url":"https://api.github.com/users/mprobst/followers","following_url":"https://api.github.com/users/mprobst/following{/other_user}","gists_url":"https://api.github.com/users/mprobst/gists{/gist_id}","starred_url":"https://api.github.com/users/mprobst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mprobst/subscriptions","organizations_url":"https://api.github.com/users/mprobst/orgs","repos_url":"https://api.github.com/users/mprobst/repos","events_url":"https://api.github.com/users/mprobst/events{/privacy}","received_events_url":"https://api.github.com/users/mprobst/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2016-02-04T01:26:06Z","updated_at":"2016-03-09T22:37:29Z","closed_at":null,"body":"When compiling `export * from 'foo';` to CommonJS module format, we end up with code like this:\r\n\r\n```js\r\nfunction __export(m) { for (var k in m) exports[k] = m; }\r\n__export(require('somemodule'));\r\n```\r\n\r\nNow surprisingly this works in Closure Compiler when replacing `require` with `goog.require`. It simply patches the `exports` to be the module name (which is a global symbol) and then the right properties end up on the right objects (yay!).\r\n\r\nHowever when importing a property that was re-exported like this, Closure Compiler complains about a missing property. It's possible to shut that off (`--jscomp_off=missingProperties`), but that seems overall dangerous - for example, dead code elimination might kill that property.\r\n\r\nIf sickle was to \"de-reference\" and re-export the particular symbols, this would avoid the problem for the time being, and allow us to continue using the hacky CommonJS --> `goog.require` transformation without having to rely on ES6 modules.\r\n\r\nAn alternative, possibly cleaner, solution would be to convert all module imports to `goog.module` and `goog.require` within sickle (including the `*` dereferencing). This would break the second compilation pass - TypeScript would no longer understand all those imports. However we have already type checked, so at that point we could just ignore all errors and emit.\r\n\r\nWDYT? @martine @rkirov "},"comment":{"url":"https://api.github.com/repos/angular/sickle/issues/comments/194545849","html_url":"https://github.com/angular/sickle/issues/47#issuecomment-194545849","issue_url":"https://api.github.com/repos/angular/sickle/issues/47","id":194545849,"user":{"login":"alexeagle","id":47395,"avatar_url":"https://avatars.githubusercontent.com/u/47395?v=3","gravatar_id":"","url":"https://api.github.com/users/alexeagle","html_url":"https://github.com/alexeagle","followers_url":"https://api.github.com/users/alexeagle/followers","following_url":"https://api.github.com/users/alexeagle/following{/other_user}","gists_url":"https://api.github.com/users/alexeagle/gists{/gist_id}","starred_url":"https://api.github.com/users/alexeagle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexeagle/subscriptions","organizations_url":"https://api.github.com/users/alexeagle/orgs","repos_url":"https://api.github.com/users/alexeagle/repos","events_url":"https://api.github.com/users/alexeagle/events{/privacy}","received_events_url":"https://api.github.com/users/alexeagle/received_events","type":"User","site_admin":false},"created_at":"2016-03-09T22:37:29Z","updated_at":"2016-03-09T22:37:29Z","body":"This is also a problem for closure compiler to re-order the imports. Using `--dependency_mode=STRICT` fails to find any require statements so the whole application is pruned away.\r\nSee http://b/27545272"}}