{"action":"created","comment":{"url":"https://api.github.com/repos/facebook/fbjs/pulls/comments/35485043","id":35485043,"diff_hunk":"@@ -0,0 +1,123 @@\n+/**\n+ * Copyright 2013-2015, Facebook, Inc.\n+ * All rights reserved.\n+ *\n+ * This source code is licensed under the BSD-style license found in the\n+ * LICENSE file in the root directory of this source tree. An additional grant\n+ * of patent rights can be found in the PATENTS file in the same directory.\n+ */\n+\n+'use strict';\n+\n+function mapModule(context, module) {\n+  // Look in options passed to babel for `_moduleMap` which contains a map of\n+  // replacements. This allows other packages to be published to npm and used\n+  // directly without being a part of the same build.\n+  var moduleMap = context.state.opts._moduleMap || {};\n+  if (moduleMap.hasOwnProperty(module)) {\n+    return moduleMap[module];\n+  }\n+  // Jest understands the haste module system, so leave modules intact.\n+  if (process.env.NODE_ENV !== 'test') {\n+    return './' + module;\n+  }\n+}\n+\n+module.exports = function(babel) {\n+  var t = babel.types;\n+\n+  /**\n+   * Transforms `require('Foo')` and `require.requireActual('Foo')`.\n+   */\n+  function transformRequireCall(context, call) {\n+    if (\n+      !t.isIdentifier(call.callee, {name: 'require'}) &&\n+      !(\n+        t.isMemberExpression(call.callee) &&\n+        t.isIdentifier(call.callee.object, {name: 'require'}) &&\n+        t.isIdentifier(call.callee.property, {name: 'requireActual'})\n+      )\n+    ) {\n+      return;\n+    }\n+    var moduleArg = call.arguments[0];\n+    if (moduleArg && moduleArg.type === 'Literal') {\n+      var module = mapModule(context, moduleArg.value);\n+      if (module) {\n+        return t.callExpression(","path":"scripts/babel/rewrite-modules.js","position":47,"original_position":47,"commit_id":"d6790dda1a280fb2cd1a69b8b30653e85d6e6ddb","original_commit_id":"d6790dda1a280fb2cd1a69b8b30653e85d6e6ddb","user":{"login":"zpao","id":8445,"avatar_url":"https://avatars.githubusercontent.com/u/8445?v=3","gravatar_id":"","url":"https://api.github.com/users/zpao","html_url":"https://github.com/zpao","followers_url":"https://api.github.com/users/zpao/followers","following_url":"https://api.github.com/users/zpao/following{/other_user}","gists_url":"https://api.github.com/users/zpao/gists{/gist_id}","starred_url":"https://api.github.com/users/zpao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zpao/subscriptions","organizations_url":"https://api.github.com/users/zpao/orgs","repos_url":"https://api.github.com/users/zpao/repos","events_url":"https://api.github.com/users/zpao/events{/privacy}","received_events_url":"https://api.github.com/users/zpao/received_events","type":"User","site_admin":false},"body":"Does this work for requireActual? Or does this fall into the same situation where we need to create a MemberExpression?","created_at":"2015-07-25T17:41:34Z","updated_at":"2015-07-25T17:41:34Z","html_url":"https://github.com/facebook/fbjs/pull/21#discussion_r35485043","pull_request_url":"https://api.github.com/repos/facebook/fbjs/pulls/21","_links":{"self":{"href":"https://api.github.com/repos/facebook/fbjs/pulls/comments/35485043"},"html":{"href":"https://github.com/facebook/fbjs/pull/21#discussion_r35485043"},"pull_request":{"href":"https://api.github.com/repos/facebook/fbjs/pulls/21"}}},"pull_request":{"url":"https://api.github.com/repos/facebook/fbjs/pulls/21","id":40834438,"html_url":"https://github.com/facebook/fbjs/pull/21","diff_url":"https://github.com/facebook/fbjs/pull/21.diff","patch_url":"https://github.com/facebook/fbjs/pull/21.patch","issue_url":"https://api.github.com/repos/facebook/fbjs/issues/21","number":21,"state":"open","locked":false,"title":"Fix Jest via Package Composition","user":{"login":"yungsters","id":55161,"avatar_url":"https://avatars.githubusercontent.com/u/55161?v=3","gravatar_id":"","url":"https://api.github.com/users/yungsters","html_url":"https://github.com/yungsters","followers_url":"https://api.github.com/users/yungsters/followers","following_url":"https://api.github.com/users/yungsters/following{/other_user}","gists_url":"https://api.github.com/users/yungsters/gists{/gist_id}","starred_url":"https://api.github.com/users/yungsters/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yungsters/subscriptions","organizations_url":"https://api.github.com/users/yungsters/orgs","repos_url":"https://api.github.com/users/yungsters/repos","events_url":"https://api.github.com/users/yungsters/events{/privacy}","received_events_url":"https://api.github.com/users/yungsters/received_events","type":"User","site_admin":false},"body":"When a package that composes `fbjs` runs Jest, some things do not currently work. In particular:\r\n\r\n - Module names are not rewritten for `require.requireActual`, `jest.dontMock`, `jest.mock`, and `jest.genMockFromModule`.\r\n - Modules using `Object.assign` or the spread operator fatal because it has not been polyfilled.\r\n - The `es6-map` polyfill pulls in `EventEmitter` which throws in the Jest environment.\r\n\r\nHere, I address these issues by:\r\n\r\n - Replacing `es6-map` with `core-js`.\r\n - Polyfill `Object.assign` in `environment.js` via `core-js`.\r\n - Add rewrite transformations for the remaining module literal strings.","created_at":"2015-07-25T09:49:39Z","updated_at":"2015-07-25T17:41:34Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e7cb1221ac5963bfb910d16271ec29fd6e212148","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/facebook/fbjs/pulls/21/commits","review_comments_url":"https://api.github.com/repos/facebook/fbjs/pulls/21/comments","review_comment_url":"https://api.github.com/repos/facebook/fbjs/pulls/comments{/number}","comments_url":"https://api.github.com/repos/facebook/fbjs/issues/21/comments","statuses_url":"https://api.github.com/repos/facebook/fbjs/statuses/d6790dda1a280fb2cd1a69b8b30653e85d6e6ddb","head":{"label":"yungsters:jest","ref":"jest","sha":"d6790dda1a280fb2cd1a69b8b30653e85d6e6ddb","user":{"login":"yungsters","id":55161,"avatar_url":"https://avatars.githubusercontent.com/u/55161?v=3","gravatar_id":"","url":"https://api.github.com/users/yungsters","html_url":"https://github.com/yungsters","followers_url":"https://api.github.com/users/yungsters/followers","following_url":"https://api.github.com/users/yungsters/following{/other_user}","gists_url":"https://api.github.com/users/yungsters/gists{/gist_id}","starred_url":"https://api.github.com/users/yungsters/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yungsters/subscriptions","organizations_url":"https://api.github.com/users/yungsters/orgs","repos_url":"https://api.github.com/users/yungsters/repos","events_url":"https://api.github.com/users/yungsters/events{/privacy}","received_events_url":"https://api.github.com/users/yungsters/received_events","type":"User","site_admin":false},"repo":{"id":39485416,"name":"fbjs","full_name":"yungsters/fbjs","owner":{"login":"yungsters","id":55161,"avatar_url":"https://avatars.githubusercontent.com/u/55161?v=3","gravatar_id":"","url":"https://api.github.com/users/yungsters","html_url":"https://github.com/yungsters","followers_url":"https://api.github.com/users/yungsters/followers","following_url":"https://api.github.com/users/yungsters/following{/other_user}","gists_url":"https://api.github.com/users/yungsters/gists{/gist_id}","starred_url":"https://api.github.com/users/yungsters/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yungsters/subscriptions","organizations_url":"https://api.github.com/users/yungsters/orgs","repos_url":"https://api.github.com/users/yungsters/repos","events_url":"https://api.github.com/users/yungsters/events{/privacy}","received_events_url":"https://api.github.com/users/yungsters/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/yungsters/fbjs","description":"A collection of utility libraries used by other Facebook JS projects.","fork":true,"url":"https://api.github.com/repos/yungsters/fbjs","forks_url":"https://api.github.com/repos/yungsters/fbjs/forks","keys_url":"https://api.github.com/repos/yungsters/fbjs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/yungsters/fbjs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/yungsters/fbjs/teams","hooks_url":"https://api.github.com/repos/yungsters/fbjs/hooks","issue_events_url":"https://api.github.com/repos/yungsters/fbjs/issues/events{/number}","events_url":"https://api.github.com/repos/yungsters/fbjs/events","assignees_url":"https://api.github.com/repos/yungsters/fbjs/assignees{/user}","branches_url":"https://api.github.com/repos/yungsters/fbjs/branches{/branch}","tags_url":"https://api.github.com/repos/yungsters/fbjs/tags","blobs_url":"https://api.github.com/repos/yungsters/fbjs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/yungsters/fbjs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/yungsters/fbjs/git/refs{/sha}","trees_url":"https://api.github.com/repos/yungsters/fbjs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/yungsters/fbjs/statuses/{sha}","languages_url":"https://api.github.com/repos/yungsters/fbjs/languages","stargazers_url":"https://api.github.com/repos/yungsters/fbjs/stargazers","contributors_url":"https://api.github.com/repos/yungsters/fbjs/contributors","subscribers_url":"https://api.github.com/repos/yungsters/fbjs/subscribers","subscription_url":"https://api.github.com/repos/yungsters/fbjs/subscription","commits_url":"https://api.github.com/repos/yungsters/fbjs/commits{/sha}","git_commits_url":"https://api.github.com/repos/yungsters/fbjs/git/commits{/sha}","comments_url":"https://api.github.com/repos/yungsters/fbjs/comments{/number}","issue_comment_url":"https://api.github.com/repos/yungsters/fbjs/issues/comments{/number}","contents_url":"https://api.github.com/repos/yungsters/fbjs/contents/{+path}","compare_url":"https://api.github.com/repos/yungsters/fbjs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/yungsters/fbjs/merges","archive_url":"https://api.github.com/repos/yungsters/fbjs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/yungsters/fbjs/downloads","issues_url":"https://api.github.com/repos/yungsters/fbjs/issues{/number}","pulls_url":"https://api.github.com/repos/yungsters/fbjs/pulls{/number}","milestones_url":"https://api.github.com/repos/yungsters/fbjs/milestones{/number}","notifications_url":"https://api.github.com/repos/yungsters/fbjs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/yungsters/fbjs/labels{/name}","releases_url":"https://api.github.com/repos/yungsters/fbjs/releases{/id}","created_at":"2015-07-22T04:24:21Z","updated_at":"2015-07-24T17:50:20Z","pushed_at":"2015-07-25T09:44:53Z","git_url":"git://github.com/yungsters/fbjs.git","ssh_url":"git@github.com:yungsters/fbjs.git","clone_url":"https://github.com/yungsters/fbjs.git","svn_url":"https://github.com/yungsters/fbjs","homepage":null,"size":171,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"facebook:master","ref":"master","sha":"6fd79d912225e0b1f4bfb7843c47c2923369f529","user":{"login":"facebook","id":69631,"avatar_url":"https://avatars.githubusercontent.com/u/69631?v=3","gravatar_id":"","url":"https://api.github.com/users/facebook","html_url":"https://github.com/facebook","followers_url":"https://api.github.com/users/facebook/followers","following_url":"https://api.github.com/users/facebook/following{/other_user}","gists_url":"https://api.github.com/users/facebook/gists{/gist_id}","starred_url":"https://api.github.com/users/facebook/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/facebook/subscriptions","organizations_url":"https://api.github.com/users/facebook/orgs","repos_url":"https://api.github.com/users/facebook/repos","events_url":"https://api.github.com/users/facebook/events{/privacy}","received_events_url":"https://api.github.com/users/facebook/received_events","type":"Organization","site_admin":false},"repo":{"id":36469177,"name":"fbjs","full_name":"facebook/fbjs","owner":{"login":"facebook","id":69631,"avatar_url":"https://avatars.githubusercontent.com/u/69631?v=3","gravatar_id":"","url":"https://api.github.com/users/facebook","html_url":"https://github.com/facebook","followers_url":"https://api.github.com/users/facebook/followers","following_url":"https://api.github.com/users/facebook/following{/other_user}","gists_url":"https://api.github.com/users/facebook/gists{/gist_id}","starred_url":"https://api.github.com/users/facebook/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/facebook/subscriptions","organizations_url":"https://api.github.com/users/facebook/orgs","repos_url":"https://api.github.com/users/facebook/repos","events_url":"https://api.github.com/users/facebook/events{/privacy}","received_events_url":"https://api.github.com/users/facebook/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/facebook/fbjs","description":"A collection of utility libraries used by other Facebook JS projects.","fork":false,"url":"https://api.github.com/repos/facebook/fbjs","forks_url":"https://api.github.com/repos/facebook/fbjs/forks","keys_url":"https://api.github.com/repos/facebook/fbjs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/facebook/fbjs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/facebook/fbjs/teams","hooks_url":"https://api.github.com/repos/facebook/fbjs/hooks","issue_events_url":"https://api.github.com/repos/facebook/fbjs/issues/events{/number}","events_url":"https://api.github.com/repos/facebook/fbjs/events","assignees_url":"https://api.github.com/repos/facebook/fbjs/assignees{/user}","branches_url":"https://api.github.com/repos/facebook/fbjs/branches{/branch}","tags_url":"https://api.github.com/repos/facebook/fbjs/tags","blobs_url":"https://api.github.com/repos/facebook/fbjs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/facebook/fbjs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/facebook/fbjs/git/refs{/sha}","trees_url":"https://api.github.com/repos/facebook/fbjs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/facebook/fbjs/statuses/{sha}","languages_url":"https://api.github.com/repos/facebook/fbjs/languages","stargazers_url":"https://api.github.com/repos/facebook/fbjs/stargazers","contributors_url":"https://api.github.com/repos/facebook/fbjs/contributors","subscribers_url":"https://api.github.com/repos/facebook/fbjs/subscribers","subscription_url":"https://api.github.com/repos/facebook/fbjs/subscription","commits_url":"https://api.github.com/repos/facebook/fbjs/commits{/sha}","git_commits_url":"https://api.github.com/repos/facebook/fbjs/git/commits{/sha}","comments_url":"https://api.github.com/repos/facebook/fbjs/comments{/number}","issue_comment_url":"https://api.github.com/repos/facebook/fbjs/issues/comments{/number}","contents_url":"https://api.github.com/repos/facebook/fbjs/contents/{+path}","compare_url":"https://api.github.com/repos/facebook/fbjs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/facebook/fbjs/merges","archive_url":"https://api.github.com/repos/facebook/fbjs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/facebook/fbjs/downloads","issues_url":"https://api.github.com/repos/facebook/fbjs/issues{/number}","pulls_url":"https://api.github.com/repos/facebook/fbjs/pulls{/number}","milestones_url":"https://api.github.com/repos/facebook/fbjs/milestones{/number}","notifications_url":"https://api.github.com/repos/facebook/fbjs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/facebook/fbjs/labels{/name}","releases_url":"https://api.github.com/repos/facebook/fbjs/releases{/id}","created_at":"2015-05-28T22:16:50Z","updated_at":"2015-07-24T09:59:30Z","pushed_at":"2015-07-25T09:49:39Z","git_url":"git://github.com/facebook/fbjs.git","ssh_url":"git@github.com:facebook/fbjs.git","clone_url":"https://github.com/facebook/fbjs.git","svn_url":"https://github.com/facebook/fbjs","homepage":null,"size":417,"stargazers_count":42,"watchers_count":42,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":3,"forks":5,"open_issues":3,"watchers":42,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/facebook/fbjs/pulls/21"},"html":{"href":"https://github.com/facebook/fbjs/pull/21"},"issue":{"href":"https://api.github.com/repos/facebook/fbjs/issues/21"},"comments":{"href":"https://api.github.com/repos/facebook/fbjs/issues/21/comments"},"review_comments":{"href":"https://api.github.com/repos/facebook/fbjs/pulls/21/comments"},"review_comment":{"href":"https://api.github.com/repos/facebook/fbjs/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/facebook/fbjs/pulls/21/commits"},"statuses":{"href":"https://api.github.com/repos/facebook/fbjs/statuses/d6790dda1a280fb2cd1a69b8b30653e85d6e6ddb"}}}}