{"action":"created","comment":{"url":"https://api.github.com/repos/babel/babel/pulls/comments/49326512","id":49326512,"diff_hunk":"@@ -33,3 +45,135 @@ require(\"babel-core\").transform(\"code\", {\n   plugins: [\"transform-runtime\"]\n });\n ```\n+\n+## Technical details\n+\n+The `runtime` transformer plugin does three things:\n+\n+* Automatically requires `babel-runtime/regenerator` when you use generators/async functions.\n+* Automatically requires `babel-runtime/core-js` and maps ES6 static methods and built-ins.\n+* Removes the inline babel helpers and uses the module `babel-runtime/helpers` instead.\n+\n+What does this actually mean though? Basically, you can use built-ins such as `Promise`, `Set`, `Symbol` etc as well use all the Babel features that require a polyfill seamlessly, without global pollution, making it extremely suitable for libraries.\n+\n+### Regenerator aliasing\n+\n+Whenever you use a generator function or async function:\n+\n+```javascript\n+function* foo() {\n+\n+}\n+\n+async function bar() {\n+\n+}\n+```\n+\n+the following is generated:\n+\n+```javascript\n+\"use strict\";\n+\n+var foo = regeneratorRuntime.mark(function foo() {\n+  ...\n+});\n+\n+function bar() {\n+  return regeneratorRuntime.async(function bar$(context$1$0) {\n+    ...\n+  }, null, this);\n+}\n+```\n+\n+This isn't ideal as then you have to include the regenerator runtime which\n+pollutes the global scope.\n+\n+Instead what the `runtime` transformer does it compile that to:\n+\n+```javascript\n+\"use strict\";\n+\n+var _regeneratorRuntime = require(\"babel-runtime/regenerator\");\n+\n+var foo = _regeneratorRuntime.mark(function foo() {\n+  ...\n+});\n+\n+function bar() {\n+  return _regeneratorRuntime.async(function bar$(context$1$0) {\n+    ...\n+  }, null, this);\n+}\n+```\n+\n+This means that you can use the regenerator runtime without polluting your current environment.\n+\n+### `core-js` aliasing\n+\n+Sometimes you may want to use new built-ins such as `Map`, `Set`, `Promise` etc. Your only way\n+to use these is usually to include a globally polluting polyfill.\n+\n+What the `runtime` transformer does is transform the following:\n+\n+```javascript\n+var sym = Symbol();\n+\n+var promise = new Promise;\n+\n+console.log(arr[Symbol.iterator]());\n+```\n+\n+into the following:\n+\n+```javascript\n+\"use strict\";\n+\n+var _core = require(\"babel-runtime/core-js\");\n+\n+var sym = _core.Symbol();\n+\n+var promise = new _core.Promise();\n+\n+console.log(_core.$for.getIterator(arr));\n+```","path":"packages/babel-plugin-transform-runtime/README.md","position":124,"original_position":124,"commit_id":"dc2e5e304b126c99ebb754e242dc4e83040283f5","original_commit_id":"dc2e5e304b126c99ebb754e242dc4e83040283f5","user":{"login":"zloirock","id":2213682,"avatar_url":"https://avatars.githubusercontent.com/u/2213682?v=3","gravatar_id":"","url":"https://api.github.com/users/zloirock","html_url":"https://github.com/zloirock","followers_url":"https://api.github.com/users/zloirock/followers","following_url":"https://api.github.com/users/zloirock/following{/other_user}","gists_url":"https://api.github.com/users/zloirock/gists{/gist_id}","starred_url":"https://api.github.com/users/zloirock/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zloirock/subscriptions","organizations_url":"https://api.github.com/users/zloirock/orgs","repos_url":"https://api.github.com/users/zloirock/repos","events_url":"https://api.github.com/users/zloirock/events{/privacy}","received_events_url":"https://api.github.com/users/zloirock/received_events","type":"User","site_admin":false},"body":"Have you tested it? :) These examples are obsolete for a long time.","created_at":"2016-01-11T14:33:51Z","updated_at":"2016-01-11T14:33:51Z","html_url":"https://github.com/babel/babel/pull/3258#discussion_r49326512","pull_request_url":"https://api.github.com/repos/babel/babel/pulls/3258","_links":{"self":{"href":"https://api.github.com/repos/babel/babel/pulls/comments/49326512"},"html":{"href":"https://github.com/babel/babel/pull/3258#discussion_r49326512"},"pull_request":{"href":"https://api.github.com/repos/babel/babel/pulls/3258"}}},"pull_request":{"url":"https://api.github.com/repos/babel/babel/pulls/3258","id":55627848,"html_url":"https://github.com/babel/babel/pull/3258","diff_url":"https://github.com/babel/babel/pull/3258.diff","patch_url":"https://github.com/babel/babel/pull/3258.patch","issue_url":"https://api.github.com/repos/babel/babel/issues/3258","number":3258,"state":"open","locked":false,"title":"Documentation for babel-plugin-transform-runtime","user":{"login":"trodrigues","id":38177,"avatar_url":"https://avatars.githubusercontent.com/u/38177?v=3","gravatar_id":"","url":"https://api.github.com/users/trodrigues","html_url":"https://github.com/trodrigues","followers_url":"https://api.github.com/users/trodrigues/followers","following_url":"https://api.github.com/users/trodrigues/following{/other_user}","gists_url":"https://api.github.com/users/trodrigues/gists{/gist_id}","starred_url":"https://api.github.com/users/trodrigues/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/trodrigues/subscriptions","organizations_url":"https://api.github.com/users/trodrigues/orgs","repos_url":"https://api.github.com/users/trodrigues/repos","events_url":"https://api.github.com/users/trodrigues/events{/privacy}","received_events_url":"https://api.github.com/users/trodrigues/received_events","type":"User","site_admin":false},"body":"Based on https://github.com/babel/babel.github.io/blob/862b43db93e48762671267034a50c30c00e433e2/docs/usage/runtime.md\r\n\r\nNot sure if the documentation from Babel 5 is still 100% accurate, but from what I could understand it seems to be.\r\n\r\nRelated to https://github.com/babel/babel.github.io/issues/674 and https://github.com/babel/babel.github.io/issues/491\r\n\r\nAlso added it to https://github.com/babel/babel.github.io/pull/678","created_at":"2016-01-11T14:26:28Z","updated_at":"2016-01-11T14:33:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bf13213cdfc59f2c400a6a56c92fe126a946e29d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/babel/babel/pulls/3258/commits","review_comments_url":"https://api.github.com/repos/babel/babel/pulls/3258/comments","review_comment_url":"https://api.github.com/repos/babel/babel/pulls/comments{/number}","comments_url":"https://api.github.com/repos/babel/babel/issues/3258/comments","statuses_url":"https://api.github.com/repos/babel/babel/statuses/dc2e5e304b126c99ebb754e242dc4e83040283f5","head":{"label":"trodrigues:patch-1","ref":"patch-1","sha":"dc2e5e304b126c99ebb754e242dc4e83040283f5","user":{"login":"trodrigues","id":38177,"avatar_url":"https://avatars.githubusercontent.com/u/38177?v=3","gravatar_id":"","url":"https://api.github.com/users/trodrigues","html_url":"https://github.com/trodrigues","followers_url":"https://api.github.com/users/trodrigues/followers","following_url":"https://api.github.com/users/trodrigues/following{/other_user}","gists_url":"https://api.github.com/users/trodrigues/gists{/gist_id}","starred_url":"https://api.github.com/users/trodrigues/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/trodrigues/subscriptions","organizations_url":"https://api.github.com/users/trodrigues/orgs","repos_url":"https://api.github.com/users/trodrigues/repos","events_url":"https://api.github.com/users/trodrigues/events{/privacy}","received_events_url":"https://api.github.com/users/trodrigues/received_events","type":"User","site_admin":false},"repo":{"id":49420561,"name":"babel","full_name":"trodrigues/babel","owner":{"login":"trodrigues","id":38177,"avatar_url":"https://avatars.githubusercontent.com/u/38177?v=3","gravatar_id":"","url":"https://api.github.com/users/trodrigues","html_url":"https://github.com/trodrigues","followers_url":"https://api.github.com/users/trodrigues/followers","following_url":"https://api.github.com/users/trodrigues/following{/other_user}","gists_url":"https://api.github.com/users/trodrigues/gists{/gist_id}","starred_url":"https://api.github.com/users/trodrigues/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/trodrigues/subscriptions","organizations_url":"https://api.github.com/users/trodrigues/orgs","repos_url":"https://api.github.com/users/trodrigues/repos","events_url":"https://api.github.com/users/trodrigues/events{/privacy}","received_events_url":"https://api.github.com/users/trodrigues/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/trodrigues/babel","description":"Babel is a compiler for writing next generation JavaScript.","fork":true,"url":"https://api.github.com/repos/trodrigues/babel","forks_url":"https://api.github.com/repos/trodrigues/babel/forks","keys_url":"https://api.github.com/repos/trodrigues/babel/keys{/key_id}","collaborators_url":"https://api.github.com/repos/trodrigues/babel/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/trodrigues/babel/teams","hooks_url":"https://api.github.com/repos/trodrigues/babel/hooks","issue_events_url":"https://api.github.com/repos/trodrigues/babel/issues/events{/number}","events_url":"https://api.github.com/repos/trodrigues/babel/events","assignees_url":"https://api.github.com/repos/trodrigues/babel/assignees{/user}","branches_url":"https://api.github.com/repos/trodrigues/babel/branches{/branch}","tags_url":"https://api.github.com/repos/trodrigues/babel/tags","blobs_url":"https://api.github.com/repos/trodrigues/babel/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/trodrigues/babel/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/trodrigues/babel/git/refs{/sha}","trees_url":"https://api.github.com/repos/trodrigues/babel/git/trees{/sha}","statuses_url":"https://api.github.com/repos/trodrigues/babel/statuses/{sha}","languages_url":"https://api.github.com/repos/trodrigues/babel/languages","stargazers_url":"https://api.github.com/repos/trodrigues/babel/stargazers","contributors_url":"https://api.github.com/repos/trodrigues/babel/contributors","subscribers_url":"https://api.github.com/repos/trodrigues/babel/subscribers","subscription_url":"https://api.github.com/repos/trodrigues/babel/subscription","commits_url":"https://api.github.com/repos/trodrigues/babel/commits{/sha}","git_commits_url":"https://api.github.com/repos/trodrigues/babel/git/commits{/sha}","comments_url":"https://api.github.com/repos/trodrigues/babel/comments{/number}","issue_comment_url":"https://api.github.com/repos/trodrigues/babel/issues/comments{/number}","contents_url":"https://api.github.com/repos/trodrigues/babel/contents/{+path}","compare_url":"https://api.github.com/repos/trodrigues/babel/compare/{base}...{head}","merges_url":"https://api.github.com/repos/trodrigues/babel/merges","archive_url":"https://api.github.com/repos/trodrigues/babel/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/trodrigues/babel/downloads","issues_url":"https://api.github.com/repos/trodrigues/babel/issues{/number}","pulls_url":"https://api.github.com/repos/trodrigues/babel/pulls{/number}","milestones_url":"https://api.github.com/repos/trodrigues/babel/milestones{/number}","notifications_url":"https://api.github.com/repos/trodrigues/babel/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/trodrigues/babel/labels{/name}","releases_url":"https://api.github.com/repos/trodrigues/babel/releases{/id}","created_at":"2016-01-11T11:06:46Z","updated_at":"2016-01-11T11:06:55Z","pushed_at":"2016-01-11T14:26:07Z","git_url":"git://github.com/trodrigues/babel.git","ssh_url":"git@github.com:trodrigues/babel.git","clone_url":"https://github.com/trodrigues/babel.git","svn_url":"https://github.com/trodrigues/babel","homepage":"https://babeljs.io/","size":12801,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"babel:master","ref":"master","sha":"69b20a3054d99a6d758aff4213ae988869b009c0","user":{"login":"babel","id":9637642,"avatar_url":"https://avatars.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":24560307,"name":"babel","full_name":"babel/babel","owner":{"login":"babel","id":9637642,"avatar_url":"https://avatars.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","description":"Babel is a compiler for writing next generation JavaScript.","fork":false,"url":"https://api.github.com/repos/babel/babel","forks_url":"https://api.github.com/repos/babel/babel/forks","keys_url":"https://api.github.com/repos/babel/babel/keys{/key_id}","collaborators_url":"https://api.github.com/repos/babel/babel/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/babel/babel/teams","hooks_url":"https://api.github.com/repos/babel/babel/hooks","issue_events_url":"https://api.github.com/repos/babel/babel/issues/events{/number}","events_url":"https://api.github.com/repos/babel/babel/events","assignees_url":"https://api.github.com/repos/babel/babel/assignees{/user}","branches_url":"https://api.github.com/repos/babel/babel/branches{/branch}","tags_url":"https://api.github.com/repos/babel/babel/tags","blobs_url":"https://api.github.com/repos/babel/babel/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/babel/babel/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/babel/babel/git/refs{/sha}","trees_url":"https://api.github.com/repos/babel/babel/git/trees{/sha}","statuses_url":"https://api.github.com/repos/babel/babel/statuses/{sha}","languages_url":"https://api.github.com/repos/babel/babel/languages","stargazers_url":"https://api.github.com/repos/babel/babel/stargazers","contributors_url":"https://api.github.com/repos/babel/babel/contributors","subscribers_url":"https://api.github.com/repos/babel/babel/subscribers","subscription_url":"https://api.github.com/repos/babel/babel/subscription","commits_url":"https://api.github.com/repos/babel/babel/commits{/sha}","git_commits_url":"https://api.github.com/repos/babel/babel/git/commits{/sha}","comments_url":"https://api.github.com/repos/babel/babel/comments{/number}","issue_comment_url":"https://api.github.com/repos/babel/babel/issues/comments{/number}","contents_url":"https://api.github.com/repos/babel/babel/contents/{+path}","compare_url":"https://api.github.com/repos/babel/babel/compare/{base}...{head}","merges_url":"https://api.github.com/repos/babel/babel/merges","archive_url":"https://api.github.com/repos/babel/babel/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/babel/babel/downloads","issues_url":"https://api.github.com/repos/babel/babel/issues{/number}","pulls_url":"https://api.github.com/repos/babel/babel/pulls{/number}","milestones_url":"https://api.github.com/repos/babel/babel/milestones{/number}","notifications_url":"https://api.github.com/repos/babel/babel/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/babel/babel/labels{/name}","releases_url":"https://api.github.com/repos/babel/babel/releases{/id}","created_at":"2014-09-28T13:38:23Z","updated_at":"2016-01-11T14:01:46Z","pushed_at":"2016-01-11T14:26:28Z","git_url":"git://github.com/babel/babel.git","ssh_url":"git@github.com:babel/babel.git","clone_url":"https://github.com/babel/babel.git","svn_url":"https://github.com/babel/babel","homepage":"https://babeljs.io/","size":13347,"stargazers_count":12949,"watchers_count":12949,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":825,"mirror_url":null,"open_issues_count":186,"forks":825,"open_issues":186,"watchers":12949,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/babel/babel/pulls/3258"},"html":{"href":"https://github.com/babel/babel/pull/3258"},"issue":{"href":"https://api.github.com/repos/babel/babel/issues/3258"},"comments":{"href":"https://api.github.com/repos/babel/babel/issues/3258/comments"},"review_comments":{"href":"https://api.github.com/repos/babel/babel/pulls/3258/comments"},"review_comment":{"href":"https://api.github.com/repos/babel/babel/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/babel/babel/pulls/3258/commits"},"statuses":{"href":"https://api.github.com/repos/babel/babel/statuses/dc2e5e304b126c99ebb754e242dc4e83040283f5"}}}}