diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp
index ced8ff4f4facfaa7ea1dac857c57706aa6946f34..568fb2642c9f27b8b1ee3a017b433dfa5b6f0b82 100644
--- a/lib/Format/TokenAnnotator.cpp
+++ b/lib/Format/TokenAnnotator.cpp
@@ -1759,7 +1759,7 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line,
     if (Right.is(TT_JsTypeColon))
       return false;
     if ((Left.is(tok::l_brace) || Right.is(tok::r_brace)) &&
-        Line.First->is(Keywords.kw_import))
+        Line.First->isOneOf(Keywords.kw_import, tok::kw_export))
       return false;
   } else if (Style.Language == FormatStyle::LK_Java) {
     if (Left.is(tok::r_square) && Right.is(tok::l_brace))
diff --git a/lib/Format/UnwrappedLineParser.cpp b/lib/Format/UnwrappedLineParser.cpp
index 43ed6364879c860fe2f2be2fafc366342846e9ce..7bab55ce42328f6b447b7d2314f3c8332687eb8c 100644
--- a/lib/Format/UnwrappedLineParser.cpp
+++ b/lib/Format/UnwrappedLineParser.cpp
@@ -262,7 +262,7 @@ bool UnwrappedLineParser::parse() {
 void UnwrappedLineParser::parseFile() {
   ScopedDeclarationState DeclarationState(
       *Line, DeclarationScopeStack,
-      /*MustBeDeclaration=*/ !Line->InPPDirective);
+      /*MustBeDeclaration=*/!Line->InPPDirective);
   parseLevel(/*HasOpeningBrace=*/false);
   // Make sure to format the remaining tokens.
   flushComments(true);
@@ -734,6 +734,12 @@ void UnwrappedLineParser::parseStructuralElement() {
       }
     }
     break;
+  case tok::kw_export:
+    if (Style.Language == FormatStyle::LK_JavaScript) {
+      parseJavaScriptEs6ImportExport();
+      return;
+    }
+    break;
   case tok::identifier:
     if (FormatTok->IsForEachMacro) {
       parseForOrWhileLoop();
@@ -741,7 +747,7 @@ void UnwrappedLineParser::parseStructuralElement() {
     }
     if (Style.Language == FormatStyle::LK_JavaScript &&
         FormatTok->is(Keywords.kw_import)) {
-      parseJavaScriptEs6Import();
+      parseJavaScriptEs6ImportExport();
       return;
     }
     // In all other cases, parse the declaration.
@@ -970,7 +976,7 @@ void UnwrappedLineParser::tryToParseJSFunction() {
 
   // Consume function name.
   if (FormatTok->is(tok::identifier))
-      nextToken();
+    nextToken();
 
   if (FormatTok->isNot(tok::l_paren))
     return;
@@ -1604,13 +1610,24 @@ void UnwrappedLineParser::parseObjCProtocol() {
   parseObjCUntilAtEnd();
 }
 
-void UnwrappedLineParser::parseJavaScriptEs6Import() {
-  assert(FormatTok->is(Keywords.kw_import));
+void UnwrappedLineParser::parseJavaScriptEs6ImportExport() {
+  assert(FormatTok->isOneOf(Keywords.kw_import, tok::kw_export));
   nextToken();
+
+  if (FormatTok->isOneOf(tok::kw_const, tok::kw_class, Keywords.kw_function,
+                         Keywords.kw_var))
+    return; // Fall through to parsing the corresponding structure.
+
+  if (FormatTok->is(tok::kw_default)) {
+    nextToken(); // export default ..., fall through after eating 'default'.
+    return;
+  }
+
   if (FormatTok->is(tok::l_brace)) {
     FormatTok->BlockKind = BK_Block;
     parseBracedList();
   }
+
   while (!eof() && FormatTok->isNot(tok::semi) &&
          FormatTok->isNot(tok::l_brace)) {
     nextToken();
diff --git a/lib/Format/UnwrappedLineParser.h b/lib/Format/UnwrappedLineParser.h
index b4430f7652499bf5586f1424ea0c9f2c1fd532aa..4b953ea6073af4608665e06be0d8ffde7396406a 100644
--- a/lib/Format/UnwrappedLineParser.h
+++ b/lib/Format/UnwrappedLineParser.h
@@ -103,7 +103,7 @@ private:
   void parseObjCUntilAtEnd();
   void parseObjCInterfaceOrImplementation();
   void parseObjCProtocol();
-  void parseJavaScriptEs6Import();
+  void parseJavaScriptEs6ImportExport();
   bool tryToParseLambda();
   bool tryToParseLambdaIntroducer();
   void tryToParseJSFunction();
diff --git a/unittests/Format/FormatTestJS.cpp b/unittests/Format/FormatTestJS.cpp
index ab4af8090bf901cf8c91d6e8890fa2be48b58efc..7c61d63a1aab756971fe94f3402cee3512a7f8b2 100644
--- a/unittests/Format/FormatTestJS.cpp
+++ b/unittests/Format/FormatTestJS.cpp
@@ -546,9 +546,30 @@ TEST_F(FormatTestJS, Modules) {
   verifyFormat("import {X as myLocalX, Y as myLocalY} from 'some/module.js';");
   verifyFormat("import * as lib from 'some/module.js';");
   verifyFormat("var x = {\n  import: 1\n};\nx.import = 2;");
-  verifyFormat("export function fn() {\n  return 'fn';\n}");
+
+  verifyFormat("export function fn() {\n"
+               "  return 'fn';\n"
+               "}");
   verifyFormat("export const x = 12;");
   verifyFormat("export default class X {}");
+  verifyFormat("export {X, Y} from 'some/module.js';");
+  verifyFormat("export {\n"
+               "  X,\n"
+               "  Y,\n"
+               "} from 'some/module.js';");
+  verifyFormat("export class C {\n"
+               "  x: number;\n"
+               "  y: string;\n"
+               "}");
+  verifyFormat("export class X { y: number; }");
+  verifyFormat("export default class X { y: number }");
+  verifyFormat("export default function() {\n  return 1;\n}");
+  verifyFormat("export var x = 12;");
+  verifyFormat("export var x: number = 12;");
+  verifyFormat("export const y = {\n"
+               "  a: 1,\n"
+               "  b: 2\n"
+               "};");
 }
 
 } // end namespace tooling