@@ -56,13 +56,15 @@ data ModuleType = CommonJS | Globals
5656moduleToJs :: ModuleType -> Options -> Module -> Environment -> [JS]
5757moduleToJs mt opts (Module name decls (Just exps)) env = case mt of
5858 CommonJS -> moduleBody ++ [JSAssignment (JSAccessor "exports" (JSVar "module")) moduleExports]
59− Globals ->
59+ Globals | not isModuleEmpty ->
6060 [ JSVariableIntroduction (fromJust (optionsBrowserNamespace opts))
6161 (Just (JSBinary Or (JSVar (fromJust (optionsBrowserNamespace opts))) (JSObjectLiteral [])) )
6262 , JSAssignment (JSAccessor (moduleNameToJs name) (JSVar (fromJust (optionsBrowserNamespace opts))))
6363 (JSApp (JSFunction Nothing [] (JSBlock (moduleBody ++ [JSReturn moduleExports]))) [])
6464 ]
65+ _ -> []
6566 where
67+ isModuleEmpty = null jsDecls
6668 moduleBody = JSStringLiteral "use strict" : jsImports ++ jsDecls
6769 moduleExports = JSObjectLiteral $ concatMap exportToJs exps
6870 jsDecls = (concat $ mapMaybe (\decl -> fmap (map $ optimize opts) $ declToJs opts name decl env) decls)