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

        compiledNodes.push node.compileNode o
      else if top
        node.front = true
        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 ";"

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