{"action":"created","issue":{"url":"https://api.github.com/repos/babel/babel-preset-env/issues/84","repository_url":"https://api.github.com/repos/babel/babel-preset-env","labels_url":"https://api.github.com/repos/babel/babel-preset-env/issues/84/labels{/name}","comments_url":"https://api.github.com/repos/babel/babel-preset-env/issues/84/comments","events_url":"https://api.github.com/repos/babel/babel-preset-env/issues/84/events","html_url":"https://github.com/babel/babel-preset-env/issues/84","id":195029405,"number":84,"title":"useBuiltIns: figure out how to remove polyfills that aren't actually used in the codebase","user":{"login":"hzoo","id":588473,"avatar_url":"https://avatars.githubusercontent.com/u/588473?v=3","gravatar_id":"","url":"https://api.github.com/users/hzoo","html_url":"https://github.com/hzoo","followers_url":"https://api.github.com/users/hzoo/followers","following_url":"https://api.github.com/users/hzoo/following{/other_user}","gists_url":"https://api.github.com/users/hzoo/gists{/gist_id}","starred_url":"https://api.github.com/users/hzoo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hzoo/subscriptions","organizations_url":"https://api.github.com/users/hzoo/orgs","repos_url":"https://api.github.com/users/hzoo/repos","events_url":"https://api.github.com/users/hzoo/events{/privacy}","received_events_url":"https://api.github.com/users/hzoo/received_events","type":"User","site_admin":false},"labels":[{"id":456631590,"url":"https://api.github.com/repos/babel/babel-preset-env/labels/discussion","name":"discussion","color":"c5def5","default":false},{"id":424467600,"url":"https://api.github.com/repos/babel/babel-preset-env/labels/enhancement","name":"enhancement","color":"84b6eb","default":true},{"id":424467601,"url":"https://api.github.com/repos/babel/babel-preset-env/labels/help%20wanted","name":"help wanted","color":"128A0C","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-12-12T17:04:39Z","updated_at":"2016-12-12T18:45:58Z","closed_at":null,"body":"## Goal: only include necessary polyfills\r\n\r\n### Don't include if supported environments support it natively #20\r\n- Use preset-env config to determine what parts of core-js to pull in (original PR, #55)\r\n\r\n```js\r\nimport \"babel-polyfill\";\r\n```\r\n\r\ngets transformed to\r\n\r\n```js\r\nimport \"core-js/modules/es6.map\";\r\nimport \"regenerator-runtime/runtime\";\r\n...\r\n```\r\n\r\n### Don't include if you have blacklisted it yourself (regenerator for example) #60\r\n- Be able to blacklist transforms or specific builtIns? \r\n\r\n```js\r\n{\r\n  \"presets\": [\r\n    [\"env\", {\r\n      \"targets\": {\r\n        \"browsers\": [\"last 2 versions\", \"safari >= 7\"]\r\n      },\r\n      \"blacklist\": [\r\n        \"transform-regenerator\" // won't include \"regenerator-runtime/runtime\"\r\n      ]\r\n    }]\r\n  ]\r\n}\r\n```\r\n\r\n---\r\n\r\n### Don't include if the codebase doesn't actually use the builtIn (this)\r\n\r\n> this would need to be a whole codebase transformation so it probably won't work in this preset/plugin\r\n\r\nThe problem with the first heading ^ is that even if you remove the polyfills supported natively in the environment, you might not actually use them in your codebase anyway.\r\n\r\nPossible solution: run an analyzer (separate babel pass like [transform-runtime](https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-runtime)) on the whole codebase and remove imports that aren't used anywhere.\r\n\r\nEDIT: A big problem atm is that Babel runs per file. So unless we understand the whole codebase it sounds like something webpack could do? cc @TheLarkInn @keyanzhang\r\n"},"comment":{"url":"https://api.github.com/repos/babel/babel-preset-env/issues/comments/266515510","html_url":"https://github.com/babel/babel-preset-env/issues/84#issuecomment-266515510","issue_url":"https://api.github.com/repos/babel/babel-preset-env/issues/84","id":266515510,"user":{"login":"EnoahNetzach","id":663755,"avatar_url":"https://avatars.githubusercontent.com/u/663755?v=3","gravatar_id":"","url":"https://api.github.com/users/EnoahNetzach","html_url":"https://github.com/EnoahNetzach","followers_url":"https://api.github.com/users/EnoahNetzach/followers","following_url":"https://api.github.com/users/EnoahNetzach/following{/other_user}","gists_url":"https://api.github.com/users/EnoahNetzach/gists{/gist_id}","starred_url":"https://api.github.com/users/EnoahNetzach/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/EnoahNetzach/subscriptions","organizations_url":"https://api.github.com/users/EnoahNetzach/orgs","repos_url":"https://api.github.com/users/EnoahNetzach/repos","events_url":"https://api.github.com/users/EnoahNetzach/events{/privacy}","received_events_url":"https://api.github.com/users/EnoahNetzach/received_events","type":"User","site_admin":false},"created_at":"2016-12-12T18:45:58Z","updated_at":"2016-12-12T18:45:58Z","body":"Something like \r\n```es6\r\nfeaturesToPolyfill.map(({ object, feature }) => {\r\n  object.prototype[feature] = (...args) => {\r\n    object.prototype[feature] = awaitFetchPolyfill(object, feature)\r\n    return object.prototype[feature](...args)\r\n  }\r\n})\r\n```\r\n  "}}
{"actor":{"display_login":"EnoahNetzach"}}