{"action":"created","comment":{"url":"https://api.github.com/repos/google/closure-compiler/pulls/comments/49736347","id":49736347,"diff_hunk":"@@ -377,57 +420,36 @@ private void processExports(Node script, String moduleName) {\n         // One top-level assign: transform to\n         // moduleName = rhs\n         Node ref = moduleExportRefs.get(0);\n-        Node newName = IR.name(moduleName);\n+        Node newName = IR.name(moduleName).srcref(ref);\n         newName.putProp(Node.ORIGINALNAME_PROP, ref.getQualifiedName());\n+        Node rhsValue = ref.getNext();\n \n-        Node rhsValue = ref.getNext().detachFromParent();\n-        Node newExprResult = IR.exprResult(IR.assign(newName, rhsValue)\n-          .useSourceInfoIfMissingFromForTree(ref.getParent()));\n-\n-        // If the rValue is an object literal, check each property to see if\n-        // it's an alias, and if it is, copy the annotation over.\n-        // This is a common idiom to export a set of constructors.\n         if (rhsValue.isObjectLit()) {\n-          Scope globalScope = SyntacticScopeCreator.makeUntyped(compiler)\n-              .createScope(script, null);\n-          for (Node key = rhsValue.getFirstChild();\n-               key != null; key = key.getNext()) {\n-            if (key.getJSDocInfo() == null &&\n-                (key.getFirstChild() == null || key.getFirstChild().isName())) {\n-              String aliasedVarName = key.getFirstChild() == null ?\n-                  key.getString() : key.getFirstChild().getString();\n-              Var aliasedVar = globalScope.getVar(aliasedVarName);\n-              JSDocInfo info =\n-                  aliasedVar == null ? null : aliasedVar.getJSDocInfo();\n-              if (info != null &&\n-                  info.getVisibility() != JSDocInfo.Visibility.PRIVATE) {\n-                key.setJSDocInfo(info);\n-              }\n-            }\n-          }\n+          addConstToObjLitKeys(rhsValue);\n         }\n \n         Node assign = ref.getParent();\n-        Node exprResult = assign.getParent();\n-        script.replaceChild(exprResult, newExprResult);\n+        assign.replaceChild(ref, newName);\n+        JSDocInfoBuilder builder = new JSDocInfoBuilder(true);\n+        builder.recordConstancy();","path":"src/com/google/javascript/jscomp/ProcessCommonJSModules.java","position":116,"original_position":121,"commit_id":"60d4431e18f23fd05e121276d2242780afdf820c","original_commit_id":"a6748f441515569d11ea7685cd7363ab79732d5d","user":{"login":"Dominator008","id":1403453,"avatar_url":"https://avatars.githubusercontent.com/u/1403453?v=3","gravatar_id":"","url":"https://api.github.com/users/Dominator008","html_url":"https://github.com/Dominator008","followers_url":"https://api.github.com/users/Dominator008/followers","following_url":"https://api.github.com/users/Dominator008/following{/other_user}","gists_url":"https://api.github.com/users/Dominator008/gists{/gist_id}","starred_url":"https://api.github.com/users/Dominator008/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Dominator008/subscriptions","organizations_url":"https://api.github.com/users/Dominator008/orgs","repos_url":"https://api.github.com/users/Dominator008/repos","events_url":"https://api.github.com/users/Dominator008/events{/privacy}","received_events_url":"https://api.github.com/users/Dominator008/received_events","type":"User","site_admin":false},"body":"We can merge this first :)","created_at":"2016-01-14T15:05:52Z","updated_at":"2016-01-14T15:05:52Z","html_url":"https://github.com/google/closure-compiler/pull/1348#discussion_r49736347","pull_request_url":"https://api.github.com/repos/google/closure-compiler/pulls/1348","_links":{"self":{"href":"https://api.github.com/repos/google/closure-compiler/pulls/comments/49736347"},"html":{"href":"https://github.com/google/closure-compiler/pull/1348#discussion_r49736347"},"pull_request":{"href":"https://api.github.com/repos/google/closure-compiler/pulls/1348"}}},"pull_request":{"url":"https://api.github.com/repos/google/closure-compiler/pulls/1348","id":54669129,"html_url":"https://github.com/google/closure-compiler/pull/1348","diff_url":"https://github.com/google/closure-compiler/pull/1348.diff","patch_url":"https://github.com/google/closure-compiler/pull/1348.patch","issue_url":"https://api.github.com/repos/google/closure-compiler/issues/1348","number":1348,"state":"open","locked":false,"title":"Add const annotations to CommonJS module exports","user":{"login":"ChadKillingsworth","id":1247639,"avatar_url":"https://avatars.githubusercontent.com/u/1247639?v=3","gravatar_id":"","url":"https://api.github.com/users/ChadKillingsworth","html_url":"https://github.com/ChadKillingsworth","followers_url":"https://api.github.com/users/ChadKillingsworth/followers","following_url":"https://api.github.com/users/ChadKillingsworth/following{/other_user}","gists_url":"https://api.github.com/users/ChadKillingsworth/gists{/gist_id}","starred_url":"https://api.github.com/users/ChadKillingsworth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ChadKillingsworth/subscriptions","organizations_url":"https://api.github.com/users/ChadKillingsworth/orgs","repos_url":"https://api.github.com/users/ChadKillingsworth/repos","events_url":"https://api.github.com/users/ChadKillingsworth/events{/privacy}","received_events_url":"https://api.github.com/users/ChadKillingsworth/received_events","type":"User","site_admin":false},"body":"To help get CommonJS to parity with ES6 modules, this changes the CommonJS module rewriting to add `@const` annotations if we can reasonably be certain that the export property was assigned exactly once.","created_at":"2015-12-28T17:06:49Z","updated_at":"2016-01-14T15:05:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0499781a866d53900ff612374bfff0dd1fdc9b52","assignee":{"login":"MatrixFrog","id":244381,"avatar_url":"https://avatars.githubusercontent.com/u/244381?v=3","gravatar_id":"","url":"https://api.github.com/users/MatrixFrog","html_url":"https://github.com/MatrixFrog","followers_url":"https://api.github.com/users/MatrixFrog/followers","following_url":"https://api.github.com/users/MatrixFrog/following{/other_user}","gists_url":"https://api.github.com/users/MatrixFrog/gists{/gist_id}","starred_url":"https://api.github.com/users/MatrixFrog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MatrixFrog/subscriptions","organizations_url":"https://api.github.com/users/MatrixFrog/orgs","repos_url":"https://api.github.com/users/MatrixFrog/repos","events_url":"https://api.github.com/users/MatrixFrog/events{/privacy}","received_events_url":"https://api.github.com/users/MatrixFrog/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/google/closure-compiler/pulls/1348/commits","review_comments_url":"https://api.github.com/repos/google/closure-compiler/pulls/1348/comments","review_comment_url":"https://api.github.com/repos/google/closure-compiler/pulls/comments{/number}","comments_url":"https://api.github.com/repos/google/closure-compiler/issues/1348/comments","statuses_url":"https://api.github.com/repos/google/closure-compiler/statuses/60d4431e18f23fd05e121276d2242780afdf820c","head":{"label":"ChadKillingsworth:commonjs-add-const","ref":"commonjs-add-const","sha":"60d4431e18f23fd05e121276d2242780afdf820c","user":{"login":"ChadKillingsworth","id":1247639,"avatar_url":"https://avatars.githubusercontent.com/u/1247639?v=3","gravatar_id":"","url":"https://api.github.com/users/ChadKillingsworth","html_url":"https://github.com/ChadKillingsworth","followers_url":"https://api.github.com/users/ChadKillingsworth/followers","following_url":"https://api.github.com/users/ChadKillingsworth/following{/other_user}","gists_url":"https://api.github.com/users/ChadKillingsworth/gists{/gist_id}","starred_url":"https://api.github.com/users/ChadKillingsworth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ChadKillingsworth/subscriptions","organizations_url":"https://api.github.com/users/ChadKillingsworth/orgs","repos_url":"https://api.github.com/users/ChadKillingsworth/repos","events_url":"https://api.github.com/users/ChadKillingsworth/events{/privacy}","received_events_url":"https://api.github.com/users/ChadKillingsworth/received_events","type":"User","site_admin":false},"repo":{"id":19463857,"name":"closure-compiler","full_name":"ChadKillingsworth/closure-compiler","owner":{"login":"ChadKillingsworth","id":1247639,"avatar_url":"https://avatars.githubusercontent.com/u/1247639?v=3","gravatar_id":"","url":"https://api.github.com/users/ChadKillingsworth","html_url":"https://github.com/ChadKillingsworth","followers_url":"https://api.github.com/users/ChadKillingsworth/followers","following_url":"https://api.github.com/users/ChadKillingsworth/following{/other_user}","gists_url":"https://api.github.com/users/ChadKillingsworth/gists{/gist_id}","starred_url":"https://api.github.com/users/ChadKillingsworth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ChadKillingsworth/subscriptions","organizations_url":"https://api.github.com/users/ChadKillingsworth/orgs","repos_url":"https://api.github.com/users/ChadKillingsworth/repos","events_url":"https://api.github.com/users/ChadKillingsworth/events{/privacy}","received_events_url":"https://api.github.com/users/ChadKillingsworth/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ChadKillingsworth/closure-compiler","description":"A JavaScript checker and optimizer.","fork":true,"url":"https://api.github.com/repos/ChadKillingsworth/closure-compiler","forks_url":"https://api.github.com/repos/ChadKillingsworth/closure-compiler/forks","keys_url":"https://api.github.com/repos/ChadKillingsworth/closure-compiler/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ChadKillingsworth/closure-compiler/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ChadKillingsworth/closure-compiler/teams","hooks_url":"https://api.github.com/repos/ChadKillingsworth/closure-compiler/hooks","issue_events_url":"https://api.github.com/repos/ChadKillingsworth/closure-compiler/issues/events{/number}","events_url":"https://api.github.com/repos/ChadKillingsworth/closure-compiler/events","assignees_url":"https://api.github.com/repos/ChadKillingsworth/closure-compiler/assignees{/user}","branches_url":"https://api.github.com/repos/ChadKillingsworth/closure-compiler/branches{/branch}","tags_url":"https://api.github.com/repos/ChadKillingsworth/closure-compiler/tags","blobs_url":"https://api.github.com/repos/ChadKillingsworth/closure-compiler/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ChadKillingsworth/closure-compiler/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ChadKillingsworth/closure-compiler/git/refs{/sha}","trees_url":"https://api.github.com/repos/ChadKillingsworth/closure-compiler/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ChadKillingsworth/closure-compiler/statuses/{sha}","languages_url":"https://api.github.com/repos/ChadKillingsworth/closure-compiler/languages","stargazers_url":"https://api.github.com/repos/ChadKillingsworth/closure-compiler/stargazers","contributors_url":"https://api.github.com/repos/ChadKillingsworth/closure-compiler/contributors","subscribers_url":"https://api.github.com/repos/ChadKillingsworth/closure-compiler/subscribers","subscription_url":"https://api.github.com/repos/ChadKillingsworth/closure-compiler/subscription","commits_url":"https://api.github.com/repos/ChadKillingsworth/closure-compiler/commits{/sha}","git_commits_url":"https://api.github.com/repos/ChadKillingsworth/closure-compiler/git/commits{/sha}","comments_url":"https://api.github.com/repos/ChadKillingsworth/closure-compiler/comments{/number}","issue_comment_url":"https://api.github.com/repos/ChadKillingsworth/closure-compiler/issues/comments{/number}","contents_url":"https://api.github.com/repos/ChadKillingsworth/closure-compiler/contents/{+path}","compare_url":"https://api.github.com/repos/ChadKillingsworth/closure-compiler/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ChadKillingsworth/closure-compiler/merges","archive_url":"https://api.github.com/repos/ChadKillingsworth/closure-compiler/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ChadKillingsworth/closure-compiler/downloads","issues_url":"https://api.github.com/repos/ChadKillingsworth/closure-compiler/issues{/number}","pulls_url":"https://api.github.com/repos/ChadKillingsworth/closure-compiler/pulls{/number}","milestones_url":"https://api.github.com/repos/ChadKillingsworth/closure-compiler/milestones{/number}","notifications_url":"https://api.github.com/repos/ChadKillingsworth/closure-compiler/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ChadKillingsworth/closure-compiler/labels{/name}","releases_url":"https://api.github.com/repos/ChadKillingsworth/closure-compiler/releases{/id}","created_at":"2014-05-05T17:09:47Z","updated_at":"2016-01-13T12:24:09Z","pushed_at":"2016-01-14T01:12:07Z","git_url":"git://github.com/ChadKillingsworth/closure-compiler.git","ssh_url":"git@github.com:ChadKillingsworth/closure-compiler.git","clone_url":"https://github.com/ChadKillingsworth/closure-compiler.git","svn_url":"https://github.com/ChadKillingsworth/closure-compiler","homepage":" https://developers.google.com/closure/compiler/","size":105807,"stargazers_count":0,"watchers_count":0,"language":"Java","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":0,"default_branch":"master"}},"base":{"label":"google:master","ref":"master","sha":"8bf585696fda2e5c192782ffb35faf9af4bc0a17","user":{"login":"google","id":1342004,"avatar_url":"https://avatars.githubusercontent.com/u/1342004?v=3","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"repo":{"id":18845024,"name":"closure-compiler","full_name":"google/closure-compiler","owner":{"login":"google","id":1342004,"avatar_url":"https://avatars.githubusercontent.com/u/1342004?v=3","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/google/closure-compiler","description":"A JavaScript checker and optimizer.","fork":false,"url":"https://api.github.com/repos/google/closure-compiler","forks_url":"https://api.github.com/repos/google/closure-compiler/forks","keys_url":"https://api.github.com/repos/google/closure-compiler/keys{/key_id}","collaborators_url":"https://api.github.com/repos/google/closure-compiler/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/google/closure-compiler/teams","hooks_url":"https://api.github.com/repos/google/closure-compiler/hooks","issue_events_url":"https://api.github.com/repos/google/closure-compiler/issues/events{/number}","events_url":"https://api.github.com/repos/google/closure-compiler/events","assignees_url":"https://api.github.com/repos/google/closure-compiler/assignees{/user}","branches_url":"https://api.github.com/repos/google/closure-compiler/branches{/branch}","tags_url":"https://api.github.com/repos/google/closure-compiler/tags","blobs_url":"https://api.github.com/repos/google/closure-compiler/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/google/closure-compiler/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/google/closure-compiler/git/refs{/sha}","trees_url":"https://api.github.com/repos/google/closure-compiler/git/trees{/sha}","statuses_url":"https://api.github.com/repos/google/closure-compiler/statuses/{sha}","languages_url":"https://api.github.com/repos/google/closure-compiler/languages","stargazers_url":"https://api.github.com/repos/google/closure-compiler/stargazers","contributors_url":"https://api.github.com/repos/google/closure-compiler/contributors","subscribers_url":"https://api.github.com/repos/google/closure-compiler/subscribers","subscription_url":"https://api.github.com/repos/google/closure-compiler/subscription","commits_url":"https://api.github.com/repos/google/closure-compiler/commits{/sha}","git_commits_url":"https://api.github.com/repos/google/closure-compiler/git/commits{/sha}","comments_url":"https://api.github.com/repos/google/closure-compiler/comments{/number}","issue_comment_url":"https://api.github.com/repos/google/closure-compiler/issues/comments{/number}","contents_url":"https://api.github.com/repos/google/closure-compiler/contents/{+path}","compare_url":"https://api.github.com/repos/google/closure-compiler/compare/{base}...{head}","merges_url":"https://api.github.com/repos/google/closure-compiler/merges","archive_url":"https://api.github.com/repos/google/closure-compiler/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/google/closure-compiler/downloads","issues_url":"https://api.github.com/repos/google/closure-compiler/issues{/number}","pulls_url":"https://api.github.com/repos/google/closure-compiler/pulls{/number}","milestones_url":"https://api.github.com/repos/google/closure-compiler/milestones{/number}","notifications_url":"https://api.github.com/repos/google/closure-compiler/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/google/closure-compiler/labels{/name}","releases_url":"https://api.github.com/repos/google/closure-compiler/releases{/id}","created_at":"2014-04-16T15:30:36Z","updated_at":"2016-01-14T14:37:31Z","pushed_at":"2016-01-14T08:49:07Z","git_url":"git://github.com/google/closure-compiler.git","ssh_url":"git@github.com:google/closure-compiler.git","clone_url":"https://github.com/google/closure-compiler.git","svn_url":"https://github.com/google/closure-compiler","homepage":" https://developers.google.com/closure/compiler/","size":106951,"stargazers_count":1922,"watchers_count":1922,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":433,"mirror_url":null,"open_issues_count":466,"forks":433,"open_issues":466,"watchers":1922,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/google/closure-compiler/pulls/1348"},"html":{"href":"https://github.com/google/closure-compiler/pull/1348"},"issue":{"href":"https://api.github.com/repos/google/closure-compiler/issues/1348"},"comments":{"href":"https://api.github.com/repos/google/closure-compiler/issues/1348/comments"},"review_comments":{"href":"https://api.github.com/repos/google/closure-compiler/pulls/1348/comments"},"review_comment":{"href":"https://api.github.com/repos/google/closure-compiler/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/google/closure-compiler/pulls/1348/commits"},"statuses":{"href":"https://api.github.com/repos/google/closure-compiler/statuses/60d4431e18f23fd05e121276d2242780afdf820c"}}}}