{"action":"closed","issue":{"url":"https://api.github.com/repos/fable-compiler/Fable/issues/497","repository_url":"https://api.github.com/repos/fable-compiler/Fable","labels_url":"https://api.github.com/repos/fable-compiler/Fable/issues/497/labels{/name}","comments_url":"https://api.github.com/repos/fable-compiler/Fable/issues/497/comments","events_url":"https://api.github.com/repos/fable-compiler/Fable/issues/497/events","html_url":"https://github.com/fable-compiler/Fable/issues/497","id":184599953,"number":497,"title":"Possible minor optimization for import expressions","user":{"login":"Pauan","id":97238,"avatar_url":"https://avatars.githubusercontent.com/u/97238?v=3","gravatar_id":"","url":"https://api.github.com/users/Pauan","html_url":"https://github.com/Pauan","followers_url":"https://api.github.com/users/Pauan/followers","following_url":"https://api.github.com/users/Pauan/following{/other_user}","gists_url":"https://api.github.com/users/Pauan/gists{/gist_id}","starred_url":"https://api.github.com/users/Pauan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Pauan/subscriptions","organizations_url":"https://api.github.com/users/Pauan/orgs","repos_url":"https://api.github.com/users/Pauan/repos","events_url":"https://api.github.com/users/Pauan/events{/privacy}","received_events_url":"https://api.github.com/users/Pauan/received_events","type":"User","site_admin":false},"labels":[{"id":326301155,"url":"https://api.github.com/repos/fable-compiler/Fable/labels/discussion","name":"discussion","color":"009800","default":false},{"id":338437889,"url":"https://api.github.com/repos/fable-compiler/Fable/labels/revisit","name":"revisit","color":"f7c6c7","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-10-22T01:28:32Z","updated_at":"2016-12-04T23:09:22Z","closed_at":"2016-12-04T23:09:22Z","body":"Consider this F# code:\n\n```\nlet foo = importMember<string> \"./foo.js\"\n```\n\nIt compiles to the following code:\n\n```\nimport { foo as foo_1 } from \"./foo.js\";\nexport var foo = foo_1;\n```\n\nHowever, this [causes an extra indirection](http://rollupjs.org/?version=0.36.3&shareable=JTdCJTIyb3B0aW9ucyUyMiUzQSU3QiUyMmZvcm1hdCUyMiUzQSUyMmVzJTIyJTJDJTIybW9kdWxlTmFtZSUyMiUzQSUyMm15QnVuZGxlJTIyJTJDJTIyZ2xvYmFscyUyMiUzQSU3QiU3RCU3RCUyQyUyMm1vZHVsZXMlMjIlM0ElNUIlN0IlMjJuYW1lJTIyJTNBJTIybWFpbi5qcyUyMiUyQyUyMmNvZGUlMjIlM0ElMjJpbXBvcnQlMjAlN0IlMjBmb28lMjBhcyUyMGZvb18xJTIwJTdEJTIwZnJvbSUyMCU1QyUyMi4lMkZmb28uanMlNUMlMjIlM0IlNUNuZXhwb3J0JTIwdmFyJTIwZm9vJTIwJTNEJTIwZm9vXzElM0IlNUNuY29uc29sZS5sb2coZm9vKSUzQiUyMiU3RCUyQyU3QiUyMm5hbWUlMjIlM0ElMjJmb28uanMlMjIlMkMlMjJjb2RlJTIyJTNBJTIyZXhwb3J0JTIwdmFyJTIwZm9vJTIwJTNEJTIwJTVDJTIyaGklNUMlMjIlM0IlMjIlN0QlNUQlN0Q=) which has an (extremely minor) performance cost.\n\nInstead, it should compile to the following code:\n\n```\nimport { foo } from \"./foo.js\";\nexport { foo };\n```\n\n[This removes the extra indirection](http://rollupjs.org/?version=0.36.3&shareable=JTdCJTIyb3B0aW9ucyUyMiUzQSU3QiUyMmZvcm1hdCUyMiUzQSUyMmVzJTIyJTJDJTIybW9kdWxlTmFtZSUyMiUzQSUyMm15QnVuZGxlJTIyJTJDJTIyZ2xvYmFscyUyMiUzQSU3QiU3RCUyQyUyMm1vZHVsZUlkJTIyJTNBJTIyJTIyJTdEJTJDJTIybW9kdWxlcyUyMiUzQSU1QiU3QiUyMm5hbWUlMjIlM0ElMjJtYWluLmpzJTIyJTJDJTIyY29kZSUyMiUzQSUyMmltcG9ydCUyMCU3QiUyMGZvbyUyMCU3RCUyMGZyb20lMjAlNUMlMjIuJTJGZm9vLmpzJTVDJTIyJTNCJTVDbmV4cG9ydCUyMCU3QiUyMGZvbyUyMCU3RCUzQiU1Q25jb25zb2xlLmxvZyhmb28pJTNCJTIyJTdEJTJDJTdCJTIybmFtZSUyMiUzQSUyMmZvby5qcyUyMiUyQyUyMmNvZGUlMjIlM0ElMjJleHBvcnQlMjB2YXIlMjBmb28lMjAlM0QlMjAlNUMlMjJoaSU1QyUyMiUzQiUyMiU3RCU1RCU3RA==) because it exports the variable directly, rather than creating a new variable.\n\nThis also affects `importDefault` and `importAll`\n\n---\n\nHowever, there is one important caveat:\n- With the old code output, if the file `foo.js` mutates the `foo` variable, the mutation will have no effect (F# will use the old value for `foo`)\n- With the new code output, if the file `foo.js` mutates the `foo` variable, the mutation will have an effect (F# will use the new value for `foo`)\n\nThis is tricky.\n\nOn the one hand, we want the mutations to be visible, because that follows ES6 module semantics.\n\nOn the other hand, the variable in F# has not been marked as `mutable`, so it's very unusual for a non-`mutable` variable to change.\n\nBecause `importMember` is used for JS interop, I think it's better for mutations to be visible, because that matches ES6 module semantics, and there might be JS code which relies upon that.\n\nThis is an extremely minor issue, so there's no rush on it at all.\n"}}
{"actor":{"display_login":"alfonsogarciacaro"}}