@@ -52,11 +52,14 @@ moduleToJs opts (Module name decls (Just exps)) env =
5252 case jsDecls of
5353 [] -> Nothing
5454 _ -> Just $ JSAssignment (JSAccessor (moduleNameToJs name) (JSVar C._ps)) $
55− JSApp (JSFunction Nothing ["module"] (JSBlock $ jsDecls ++ [JSReturn $ JSVar "module"]))
56− [JSBinary Or (JSAccessor (moduleNameToJs name) (JSVar C._ps)) (JSObjectLiteral [])]
55+ JSApp (JSFunction Nothing [] (JSBlock $
56+ JSVariableIntroduction "module" (Just $ JSObjectLiteral []) :
57+ jsDecls ++
58+ jsExports ++
59+ [JSReturn $ JSVar "module"])) []
5760 where
5861 jsDecls = (concat $ mapMaybe (\decl -> fmap (map $ optimize opts) $ declToJs opts name decl env) decls)
59− ++ concatMap exportToJs exps
62+ jsExports = concatMap exportToJs exps
6063moduleToJs _ _ _ = error "Exports should have been elaborated in name desugaring"
6164
6265-- |