git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Restore module merging in generated code
5a782ceGary Burgess
src/Language/PureScript/CodeGen/JS.hs+2−2
@@ -55,7 +55,7 @@ moduleToJs :: Options -> Module -> Environment -> JS
55moduleToJs opts (Module pname@(ProperName name) decls) env =
55moduleToJs opts (Module pname@(ProperName name) decls) env =
56 JSAssignment (JSAccessor name (JSVar "_ps")) $ JSApp (JSFunction Nothing ["module"]
56 JSAssignment (JSAccessor name (JSVar "_ps")) $ JSApp (JSFunction Nothing ["module"]
57 (JSBlock $ jsDecls ++ [JSReturn $ JSVar "module"]))
57 (JSBlock $ jsDecls ++ [JSReturn $ JSVar "module"]))
58− [JSObjectLiteral []]
58+ [(JSBinary Or (JSAccessor name (JSVar "_ps")) (JSObjectLiteral []))]
59 where
59 where
60 jsDecls = (concat $ mapMaybe (\decl -> fmap (map $ optimize opts) $ declToJs opts (ModuleName pname) decl env) (decls))
60 jsDecls = (concat $ mapMaybe (\decl -> fmap (map $ optimize opts) $ declToJs opts (ModuleName pname) decl env) (decls))
61
61
@@ -347,5 +347,5 @@ wrapExportsContainer modules = JSApp (JSFunction Nothing ["_ps"] $ JSBlock $ (JS
347 where exportSelector = JSConditional (JSBinary And (JSBinary NotEqualTo (JSTypeOf $ JSVar "module") (JSStringLiteral "undefined")) (JSAccessor "exports" (JSVar "module")))
347 where exportSelector = JSConditional (JSBinary And (JSBinary NotEqualTo (JSTypeOf $ JSVar "module") (JSStringLiteral "undefined")) (JSAccessor "exports" (JSVar "module")))
348 (JSAccessor "exports" (JSVar "module"))
348 (JSAccessor "exports" (JSVar "module"))
349 (JSConditional (JSBinary NotEqualTo (JSTypeOf $ JSVar "window") (JSStringLiteral "undefined"))
349 (JSConditional (JSBinary NotEqualTo (JSTypeOf $ JSVar "window") (JSStringLiteral "undefined"))
350− (JSAssignment (JSAccessor "PS" (JSVar "window")) (JSObjectLiteral []))
350+ (JSAssignment (JSAccessor "PS" (JSVar "window")) (JSBinary Or (JSAccessor "PS" (JSVar "window")) (JSObjectLiteral [])))
351 (JSApp (JSFunction Nothing [] $ JSBlock [JSThrow $ JSStringLiteral "PureScript doesn't know how to export modules in the current environment"]) []))
351 (JSApp (JSFunction Nothing [] $ JSBlock [JSThrow $ JSStringLiteral "PureScript doesn't know how to export modules in the current environment"]) []))