{"action":"created","issue":{"url":"https://api.github.com/repos/rollup/rollup/issues/733","repository_url":"https://api.github.com/repos/rollup/rollup","labels_url":"https://api.github.com/repos/rollup/rollup/issues/733/labels{/name}","comments_url":"https://api.github.com/repos/rollup/rollup/issues/733/comments","events_url":"https://api.github.com/repos/rollup/rollup/issues/733/events","html_url":"https://github.com/rollup/rollup/issues/733","id":161082405,"number":733,"title":"Import with side-effects ignored if affected thing not exported.","user":{"login":"mbostock","id":230541,"avatar_url":"https://avatars.githubusercontent.com/u/230541?v=3","gravatar_id":"","url":"https://api.github.com/users/mbostock","html_url":"https://github.com/mbostock","followers_url":"https://api.github.com/users/mbostock/followers","following_url":"https://api.github.com/users/mbostock/following{/other_user}","gists_url":"https://api.github.com/users/mbostock/gists{/gist_id}","starred_url":"https://api.github.com/users/mbostock/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mbostock/subscriptions","organizations_url":"https://api.github.com/users/mbostock/orgs","repos_url":"https://api.github.com/users/mbostock/repos","events_url":"https://api.github.com/users/mbostock/events{/privacy}","received_events_url":"https://api.github.com/users/mbostock/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-06-19T17:16:17Z","updated_at":"2016-06-21T21:49:25Z","closed_at":null,"body":"Here’s an interesting case with [d3-selection](https://github.com/d3/d3-selection) and [d3-selection-multi](https://github.com/d3/d3-selection-multi), of which the latter mutates the selection.prototype of the [selection](https://github.com/d3/d3-selection#selection) class exported by d3-selection.\r\n\r\nIf I Rollup a bundle that does not export selection, then Rollup thinks that the selection class is unused, and so ignores the import of d3-selection-multi:\r\n\r\n```js\r\nimport {selection, select} from \"d3-selection\";\r\nimport \"d3-selection-multi\";\r\n\r\nselect(\"body\").append(\"h1\")\r\n    .text(\"Hello, world!\")\r\n    .styles({\"text-align\": \"center\"}); // TypeError! selection.styles is not a function\r\n```\r\n\r\nBut if I export selection, it works:\r\n\r\n```js\r\nimport {selection, select} from \"d3-selection\";\r\nimport \"d3-selection-multi\";\r\n\r\nexport {selection}; // 🌶\r\n\r\nselect(\"body\").append(\"h1\")\r\n    .text(\"Hello, world!\")\r\n    .styles({\"text-align\": \"center\"}); // 👍 \r\n```\r\n\r\nOf course, there’s no reason to export anything when creating an IIFE bundle of your application and not a library, so it’s not a great workaround…\r\n\r\nRelated d3/d3-selection-multi#6, /cc @LeartS."},"comment":{"url":"https://api.github.com/repos/rollup/rollup/issues/comments/227583173","html_url":"https://github.com/rollup/rollup/issues/733#issuecomment-227583173","issue_url":"https://api.github.com/repos/rollup/rollup/issues/733","id":227583173,"user":{"login":"Rich-Harris","id":1162160,"avatar_url":"https://avatars.githubusercontent.com/u/1162160?v=3","gravatar_id":"","url":"https://api.github.com/users/Rich-Harris","html_url":"https://github.com/Rich-Harris","followers_url":"https://api.github.com/users/Rich-Harris/followers","following_url":"https://api.github.com/users/Rich-Harris/following{/other_user}","gists_url":"https://api.github.com/users/Rich-Harris/gists{/gist_id}","starred_url":"https://api.github.com/users/Rich-Harris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Rich-Harris/subscriptions","organizations_url":"https://api.github.com/users/Rich-Harris/orgs","repos_url":"https://api.github.com/users/Rich-Harris/repos","events_url":"https://api.github.com/users/Rich-Harris/events{/privacy}","received_events_url":"https://api.github.com/users/Rich-Harris/received_events","type":"User","site_admin":false},"created_at":"2016-06-21T21:49:25Z","updated_at":"2016-06-21T21:49:25Z","body":"Thanks – you have a real knack for finding the edge cases 😀  Have opened #738"}}
{"actor":{"display_login":"Rich-Harris"}}