code: private void maybeUpdateExportDeclaration(NodeTraversal t, Node n) {
      if (!currentScript.isModule
          || !n.getString().equals("exports")
          || !isAssignTarget(n)) {
        return;
      }
  
      Node assignNode = n.getParent();
      if (!currentScript.declareLegacyNamespace
          && currentScript.defaultExportLocalName != null) {
        assignNode.getParent().detach();
        return;
      }
  
      // Rewrite "exports = ..." as "var module$exports$foo$Bar = ..."
      Node rhs = assignNode.getLastChild();
      Node jsdocNode;
      if (currentScript.declareLegacyNamespace) {
        Node legacyQname = NodeUtil.newQName(compiler, currentScript.legacyNamespace).srcrefTree(n);
        assignNode.replaceChild(n, legacyQname);
        jsdocNode = assignNode;
      } else {
        rhs.detach();
        Node exprResultNode = assignNode.getParent();
        Node binaryNamespaceName = IR.name(currentScript.getBinaryNamespace());
        binaryNamespaceName.setOriginalName(currentScript.legacyNamespace);
        Node exportsObjectCreationNode = IR.var(binaryNamespaceName, rhs);
        exportsObjectCreationNode.useSourceInfoIfMissingFromForTree(exprResultNode);
        exportsObjectCreationNode.putBooleanProp(Node.IS_NAMESPACE, true);
        exprResultNode.replaceWith(exportsObjectCreationNode);
        jsdocNode = exportsObjectCreationNode;
        currentScript.hasCreatedExportObject = true;
      }
      markConstAndCopyJsDoc(assignNode, jsdocNode);
      compiler.reportChangeToEnclosingScope(jsdocNode);
  
      maybeUpdateExportObjectLiteral(t, rhs);
      return;
    }
docs: In module "foo.Bar", rewrite "exports = Bar" to "var module$exports$foo$Bar = Bar".