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