{"action":"created","comment":{"url":"https://api.github.com/repos/babel/babel-preset-env/pulls/comments/110179056","pull_request_review_id":31332290,"id":110179056,"diff_hunk":"@@ -242,8 +242,11 @@ export default function buildPreset(context, opts = {}) {\n     ]),\n   );\n \n-  useBuiltIns &&\n-    plugins.push([transformPolyfillRequirePlugin, { polyfills, regenerator }]);\n+  if (useBuiltIns === true) {\n+    plugins.push([addUsedBuiltInsPlugin, { polyfills, regenerator, debug }]);","path":"src/index.js","position":18,"original_position":18,"commit_id":"ebf77d82181ac0be44153cd2041a9cdd9a0c4e08","original_commit_id":"ebf77d82181ac0be44153cd2041a9cdd9a0c4e08","user":{"login":"hzoo","id":588473,"avatar_url":"https://avatars2.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},"body":"Maybe we don't want to have those warnings, not sure if it's useful or not but we can iterate","created_at":"2017-04-06T14:39:08Z","updated_at":"2017-04-06T14:39:08Z","html_url":"https://github.com/babel/babel-preset-env/pull/241#discussion_r110179056","pull_request_url":"https://api.github.com/repos/babel/babel-preset-env/pulls/241","_links":{"self":{"href":"https://api.github.com/repos/babel/babel-preset-env/pulls/comments/110179056"},"html":{"href":"https://github.com/babel/babel-preset-env/pull/241#discussion_r110179056"},"pull_request":{"href":"https://api.github.com/repos/babel/babel-preset-env/pulls/241"}}},"pull_request":{"url":"https://api.github.com/repos/babel/babel-preset-env/pulls/241","id":113720600,"html_url":"https://github.com/babel/babel-preset-env/pull/241","diff_url":"https://github.com/babel/babel-preset-env/pull/241.diff","patch_url":"https://github.com/babel/babel-preset-env/pull/241.patch","issue_url":"https://api.github.com/repos/babel/babel-preset-env/issues/241","number":241,"state":"open","locked":false,"title":"Breaking: make current \"useBuiltIns\" auto import only used + necessary polyfills per file","user":{"login":"hzoo","id":588473,"avatar_url":"https://avatars2.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},"body":"https://twitter.com/left_pad/status/847911365645938690\r\n\r\nRef https://github.com/babel/babel-preset-env/issues/84\r\n\r\nTL;DR: automatically **add** polyfills based on actual usage in the file (check the presence of `Promise`), and **remove**  any polyfills supported by the target environment (Chrome 55 already supports `Promise`). Check the tests in this pr for more examples!\r\n\r\nSize savings: if you don't use any polyfills in your code: then none will be added. If you do use polyfills, only the ones not supported in your target environment will be added.\r\n\r\n### Examples\r\n\r\n## Older browser (like IE): imports are added\r\n\r\n![screen shot 2017-03-31 at 4 12 39 pm](https://cloud.githubusercontent.com/assets/588473/24567735/fc4d6ca0-162c-11e7-8237-f0852ef40a0f.png)\r\n\r\n## Modern browser (Chrome 58): no imports added\r\n\r\n![screen shot 2017-03-31 at 4 17 53 pm](https://cloud.githubusercontent.com/assets/588473/24567907/a5a1d4c6-162d-11e7-8d3f-fdbfe001d7f5.png)\r\n\r\n---\r\n\r\n\r\nastexplorer live example (only the adding part): http://astexplorer.net/#/gist/dc031f702921a727ec5f82c2bc3341b0/6b87729fb2ed77e8512c0b137e8a3c19dbcdc63c\r\n\r\n---\r\n\r\nThe only issue not covered in https://github.com/babel/babel-preset-env/issues/84#issuecomment-267235999 is regarding the rest of node_modules (3rd party).\r\n\r\nBasically the issue is that if you don't use `Promise` in any of the code that you run Babel on, this option doesn't know to include the `Promise` polyfill if a library you use needs it.\r\n\r\nA workaround is a disclaimer of the option and to use `includes` instead. We can even warn if you include but it's natively supported.\r\n\r\n---\r\n\r\nNot sure about the option name, or if we should making a breaking change for it. It does seem like this should be opt-in since it doesn't know about the use of polyfills in 3rd party modules unless you run babel over those too\r\n\r\n- [x] more tests (suggest some more?)\r\n- [x] change the console.warn on instance methods to be part of the debug flag?\r\n- [x] change option to be useBuiltIns, and move current option to be `useBuiltIns: \"entry\"`\r\n- [x] fix import not being transform (due to use of Program.exit, should change to adding the imports in the visitors themselves)\r\n","created_at":"2017-03-31T19:52:28Z","updated_at":"2017-04-06T14:39:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"864870b5714c49074ec1e6fe15bcac7e83f7cdaf","assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/babel/babel-preset-env/milestones/1","html_url":"https://github.com/babel/babel-preset-env/milestone/1","labels_url":"https://api.github.com/repos/babel/babel-preset-env/milestones/1/labels","id":2361279,"number":1,"title":"2.0","description":"","creator":{"login":"existentialism","id":56288,"avatar_url":"https://avatars0.githubusercontent.com/u/56288?v=3","gravatar_id":"","url":"https://api.github.com/users/existentialism","html_url":"https://github.com/existentialism","followers_url":"https://api.github.com/users/existentialism/followers","following_url":"https://api.github.com/users/existentialism/following{/other_user}","gists_url":"https://api.github.com/users/existentialism/gists{/gist_id}","starred_url":"https://api.github.com/users/existentialism/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/existentialism/subscriptions","organizations_url":"https://api.github.com/users/existentialism/orgs","repos_url":"https://api.github.com/users/existentialism/repos","events_url":"https://api.github.com/users/existentialism/events{/privacy}","received_events_url":"https://api.github.com/users/existentialism/received_events","type":"User","site_admin":false},"open_issues":6,"closed_issues":7,"state":"open","created_at":"2017-03-03T14:30:59Z","updated_at":"2017-04-05T22:09:09Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/babel/babel-preset-env/pulls/241/commits","review_comments_url":"https://api.github.com/repos/babel/babel-preset-env/pulls/241/comments","review_comment_url":"https://api.github.com/repos/babel/babel-preset-env/pulls/comments{/number}","comments_url":"https://api.github.com/repos/babel/babel-preset-env/issues/241/comments","statuses_url":"https://api.github.com/repos/babel/babel-preset-env/statuses/ebf77d82181ac0be44153cd2041a9cdd9a0c4e08","head":{"label":"babel:add-used-built-ins","ref":"add-used-built-ins","sha":"ebf77d82181ac0be44153cd2041a9cdd9a0c4e08","user":{"login":"babel","id":9637642,"avatar_url":"https://avatars2.githubusercontent.com/u/9637642?v=3","gravatar_id":"","url":"https://api.github.com/users/babel","html_url":"https://github.com/babel","followers_url":"https://api.github.com/users/babel/followers","following_url":"https://api.github.com/users/babel/following{/other_user}","gists_url":"https://api.github.com/users/babel/gists{/gist_id}","starred_url":"https://api.github.com/users/babel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/babel/subscriptions","organizations_url":"https://api.github.com/users/babel/orgs","repos_url":"https://api.github.com/users/babel/repos","events_url":"https://api.github.com/users/babel/events{/privacy}","received_events_url":"https://api.github.com/users/babel/received_events","type":"Organization","site_admin":false},"repo":{"id":65648767,"name":"babel-preset-env","full_name":"babel/babel-preset-env","owner":{"login":"babel","id":9637642,"avatar_url":"https://avatars2.githubusercontent.com/u/9637642?v=3","gravatar_id":"","url":"https://api.github.com/users/babel","html_url":"https://github.com/babel","followers_url":"https://api.github.com/users/babel/followers","following_url":"https://api.github.com/users/babel/following{/other_user}","gists_url":"https://api.github.com/users/babel/gists{/gist_id}","starred_url":"https://api.github.com/users/babel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/babel/subscriptions","organizations_url":"https://api.github.com/users/babel/orgs","repos_url":"https://api.github.com/users/babel/repos","events_url":"https://api.github.com/users/babel/events{/privacy}","received_events_url":"https://api.github.com/users/babel/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/babel/babel-preset-env","description":":earth_americas: Autoprefixer for Babel: compile less","fork":false,"url":"https://api.github.com/repos/babel/babel-preset-env","forks_url":"https://api.github.com/repos/babel/babel-preset-env/forks","keys_url":"https://api.github.com/repos/babel/babel-preset-env/keys{/key_id}","collaborators_url":"https://api.github.com/repos/babel/babel-preset-env/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/babel/babel-preset-env/teams","hooks_url":"https://api.github.com/repos/babel/babel-preset-env/hooks","issue_events_url":"https://api.github.com/repos/babel/babel-preset-env/issues/events{/number}","events_url":"https://api.github.com/repos/babel/babel-preset-env/events","assignees_url":"https://api.github.com/repos/babel/babel-preset-env/assignees{/user}","branches_url":"https://api.github.com/repos/babel/babel-preset-env/branches{/branch}","tags_url":"https://api.github.com/repos/babel/babel-preset-env/tags","blobs_url":"https://api.github.com/repos/babel/babel-preset-env/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/babel/babel-preset-env/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/babel/babel-preset-env/git/refs{/sha}","trees_url":"https://api.github.com/repos/babel/babel-preset-env/git/trees{/sha}","statuses_url":"https://api.github.com/repos/babel/babel-preset-env/statuses/{sha}","languages_url":"https://api.github.com/repos/babel/babel-preset-env/languages","stargazers_url":"https://api.github.com/repos/babel/babel-preset-env/stargazers","contributors_url":"https://api.github.com/repos/babel/babel-preset-env/contributors","subscribers_url":"https://api.github.com/repos/babel/babel-preset-env/subscribers","subscription_url":"https://api.github.com/repos/babel/babel-preset-env/subscription","commits_url":"https://api.github.com/repos/babel/babel-preset-env/commits{/sha}","git_commits_url":"https://api.github.com/repos/babel/babel-preset-env/git/commits{/sha}","comments_url":"https://api.github.com/repos/babel/babel-preset-env/comments{/number}","issue_comment_url":"https://api.github.com/repos/babel/babel-preset-env/issues/comments{/number}","contents_url":"https://api.github.com/repos/babel/babel-preset-env/contents/{+path}","compare_url":"https://api.github.com/repos/babel/babel-preset-env/compare/{base}...{head}","merges_url":"https://api.github.com/repos/babel/babel-preset-env/merges","archive_url":"https://api.github.com/repos/babel/babel-preset-env/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/babel/babel-preset-env/downloads","issues_url":"https://api.github.com/repos/babel/babel-preset-env/issues{/number}","pulls_url":"https://api.github.com/repos/babel/babel-preset-env/pulls{/number}","milestones_url":"https://api.github.com/repos/babel/babel-preset-env/milestones{/number}","notifications_url":"https://api.github.com/repos/babel/babel-preset-env/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/babel/babel-preset-env/labels{/name}","releases_url":"https://api.github.com/repos/babel/babel-preset-env/releases{/id}","deployments_url":"https://api.github.com/repos/babel/babel-preset-env/deployments","created_at":"2016-08-14T03:48:33Z","updated_at":"2017-04-06T14:20:52Z","pushed_at":"2017-04-06T13:09:45Z","git_url":"git://github.com/babel/babel-preset-env.git","ssh_url":"git@github.com:babel/babel-preset-env.git","clone_url":"https://github.com/babel/babel-preset-env.git","svn_url":"https://github.com/babel/babel-preset-env","homepage":"https://github.com/babel/babel/pull/3476","size":538,"stargazers_count":2077,"watchers_count":2077,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":64,"mirror_url":null,"open_issues_count":41,"forks":64,"open_issues":41,"watchers":2077,"default_branch":"master"}},"base":{"label":"babel:2.0","ref":"2.0","sha":"c50d3302b173f4b9fc12b2bbb612bdc84c576cc1","user":{"login":"babel","id":9637642,"avatar_url":"https://avatars2.githubusercontent.com/u/9637642?v=3","gravatar_id":"","url":"https://api.github.com/users/babel","html_url":"https://github.com/babel","followers_url":"https://api.github.com/users/babel/followers","following_url":"https://api.github.com/users/babel/following{/other_user}","gists_url":"https://api.github.com/users/babel/gists{/gist_id}","starred_url":"https://api.github.com/users/babel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/babel/subscriptions","organizations_url":"https://api.github.com/users/babel/orgs","repos_url":"https://api.github.com/users/babel/repos","events_url":"https://api.github.com/users/babel/events{/privacy}","received_events_url":"https://api.github.com/users/babel/received_events","type":"Organization","site_admin":false},"repo":{"id":65648767,"name":"babel-preset-env","full_name":"babel/babel-preset-env","owner":{"login":"babel","id":9637642,"avatar_url":"https://avatars2.githubusercontent.com/u/9637642?v=3","gravatar_id":"","url":"https://api.github.com/users/babel","html_url":"https://github.com/babel","followers_url":"https://api.github.com/users/babel/followers","following_url":"https://api.github.com/users/babel/following{/other_user}","gists_url":"https://api.github.com/users/babel/gists{/gist_id}","starred_url":"https://api.github.com/users/babel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/babel/subscriptions","organizations_url":"https://api.github.com/users/babel/orgs","repos_url":"https://api.github.com/users/babel/repos","events_url":"https://api.github.com/users/babel/events{/privacy}","received_events_url":"https://api.github.com/users/babel/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/babel/babel-preset-env","description":":earth_americas: Autoprefixer for Babel: compile less","fork":false,"url":"https://api.github.com/repos/babel/babel-preset-env","forks_url":"https://api.github.com/repos/babel/babel-preset-env/forks","keys_url":"https://api.github.com/repos/babel/babel-preset-env/keys{/key_id}","collaborators_url":"https://api.github.com/repos/babel/babel-preset-env/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/babel/babel-preset-env/teams","hooks_url":"https://api.github.com/repos/babel/babel-preset-env/hooks","issue_events_url":"https://api.github.com/repos/babel/babel-preset-env/issues/events{/number}","events_url":"https://api.github.com/repos/babel/babel-preset-env/events","assignees_url":"https://api.github.com/repos/babel/babel-preset-env/assignees{/user}","branches_url":"https://api.github.com/repos/babel/babel-preset-env/branches{/branch}","tags_url":"https://api.github.com/repos/babel/babel-preset-env/tags","blobs_url":"https://api.github.com/repos/babel/babel-preset-env/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/babel/babel-preset-env/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/babel/babel-preset-env/git/refs{/sha}","trees_url":"https://api.github.com/repos/babel/babel-preset-env/git/trees{/sha}","statuses_url":"https://api.github.com/repos/babel/babel-preset-env/statuses/{sha}","languages_url":"https://api.github.com/repos/babel/babel-preset-env/languages","stargazers_url":"https://api.github.com/repos/babel/babel-preset-env/stargazers","contributors_url":"https://api.github.com/repos/babel/babel-preset-env/contributors","subscribers_url":"https://api.github.com/repos/babel/babel-preset-env/subscribers","subscription_url":"https://api.github.com/repos/babel/babel-preset-env/subscription","commits_url":"https://api.github.com/repos/babel/babel-preset-env/commits{/sha}","git_commits_url":"https://api.github.com/repos/babel/babel-preset-env/git/commits{/sha}","comments_url":"https://api.github.com/repos/babel/babel-preset-env/comments{/number}","issue_comment_url":"https://api.github.com/repos/babel/babel-preset-env/issues/comments{/number}","contents_url":"https://api.github.com/repos/babel/babel-preset-env/contents/{+path}","compare_url":"https://api.github.com/repos/babel/babel-preset-env/compare/{base}...{head}","merges_url":"https://api.github.com/repos/babel/babel-preset-env/merges","archive_url":"https://api.github.com/repos/babel/babel-preset-env/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/babel/babel-preset-env/downloads","issues_url":"https://api.github.com/repos/babel/babel-preset-env/issues{/number}","pulls_url":"https://api.github.com/repos/babel/babel-preset-env/pulls{/number}","milestones_url":"https://api.github.com/repos/babel/babel-preset-env/milestones{/number}","notifications_url":"https://api.github.com/repos/babel/babel-preset-env/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/babel/babel-preset-env/labels{/name}","releases_url":"https://api.github.com/repos/babel/babel-preset-env/releases{/id}","deployments_url":"https://api.github.com/repos/babel/babel-preset-env/deployments","created_at":"2016-08-14T03:48:33Z","updated_at":"2017-04-06T14:20:52Z","pushed_at":"2017-04-06T13:09:45Z","git_url":"git://github.com/babel/babel-preset-env.git","ssh_url":"git@github.com:babel/babel-preset-env.git","clone_url":"https://github.com/babel/babel-preset-env.git","svn_url":"https://github.com/babel/babel-preset-env","homepage":"https://github.com/babel/babel/pull/3476","size":538,"stargazers_count":2077,"watchers_count":2077,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":64,"mirror_url":null,"open_issues_count":41,"forks":64,"open_issues":41,"watchers":2077,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/babel/babel-preset-env/pulls/241"},"html":{"href":"https://github.com/babel/babel-preset-env/pull/241"},"issue":{"href":"https://api.github.com/repos/babel/babel-preset-env/issues/241"},"comments":{"href":"https://api.github.com/repos/babel/babel-preset-env/issues/241/comments"},"review_comments":{"href":"https://api.github.com/repos/babel/babel-preset-env/pulls/241/comments"},"review_comment":{"href":"https://api.github.com/repos/babel/babel-preset-env/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/babel/babel-preset-env/pulls/241/commits"},"statuses":{"href":"https://api.github.com/repos/babel/babel-preset-env/statuses/ebf77d82181ac0be44153cd2041a9cdd9a0c4e08"}}}}
{"actor":{"display_login":"hzoo"}}