         compiledNodes.push node.compileNode o
       else if top
         node.front = true
+        if @exportAll then node.match [  # add assignment in here
+          M("exported", Class), M("exported", Code)
+          new Assign(any, M("exported", Code)).when((a)->a.isCodeDef())
+          ({exported}) =>
+            exported.shouldExport = yes
+        ]
         fragments = node.compileToFragments o
-        if @exportAll then node.match [  # add assignment in here
-          Class, Code, new Assign(any, any).when((a)->a.isCodeDef()), () =>
-            fragments.unshift @makeCode "export "
-        ]
         unless node.isStatement o
           fragments.unshift @makeCode "#{@tab}"
           fragments.push @makeCode ";"

          ]
        [argscode, @makeCode(' => '), bodycode]
      else if @name? and not @bound
        [@makeCode("#{@tab}function "), @name.compileNode(o), argscode, bodycode]
      else if not @bound
        [@makeCode("function"), argscode, bodycode]
      else

    prelude = []
    declaration = [
      @makeCode indent
      @makeCode if @shouldExport then "export " else ""
      @makeCode "class #{name}"
      if @parent then [
        @makeCode( " extends "),
