diff --git a/Yesod/Fay.hs b/Yesod/Fay.hs
--- a/Yesod/Fay.hs
+++ b/Yesod/Fay.hs
@@ -98,12 +98,14 @@
 import           Data.Text.Lazy.Builder     (fromText, toLazyText, Builder)
 import           Filesystem                 (createTree, isFile, readTextFile)
 import           Filesystem.Path.CurrentOS  (directory, encodeString, decodeString)
-import           Fay                        (compileFileWithState, CompileState(..), getRuntime)
+import           Fay                        (compileFileWithState, CompileState(..), getRuntime,
+                                             showCompileError)
 import           Fay.Convert                (showToFay)
 import           Fay.Types                  (CompileConfig(..),
                                              configDirectoryIncludes,
                                              configTypecheck,
                                              configExportRuntime,
+                                             configPrettyPrint,
                                              CompileError)
 import           Language.Fay.Yesod         (Returns (Returns))
 import           Language.Haskell.TH.Syntax (Exp (LitE), Lit (StringL),
@@ -119,13 +121,6 @@
 import           Yesod.Form.Jquery          (YesodJquery (..))
 import           Yesod.Static
 
-jsMainCall :: Bool -> String -> Builder
-jsMainCall False _ = mempty
-jsMainCall True mn' =
-    "Fay$$_(" <> mn <> ".main);"
-  where
-    mn = fromText $ T.pack mn'
-
 -- | Type class for applications using Fay.
 --
 -- We depend on @YesodJquery@ since the generated client-side code uses jQuery
@@ -189,6 +184,10 @@
     -- jQuery to be present. If you disable this option and still use the
     -- provided server call functions, your code will break.
     , yfsPackages        :: [String]
+    , yfsTypecheckDevel  :: Bool
+    -- ^ Perform typechecking when in devel mode?
+    --
+    -- Default: False
     }
 
 yesodFaySettings :: String -> YesodFaySettings
@@ -199,6 +198,7 @@
     , yfsExternal = Nothing
     , yfsRequireJQuery = True
     , yfsPackages = ["fay-base"]
+    , yfsTypecheckDevel = False
     }
 
 updateRuntime :: FilePath -> IO ()
@@ -343,10 +343,10 @@
         , configPackages = packages
         }
     case eres of
-        Left e -> error $ "Unable to compile Fay module \"" ++ name ++ "\": " ++ show e
+        Left e -> throwFayError name e
         Right s -> do
             s' <- qRunIO $ yfsPostProcess settings s
-            let contents = fromText (pack s') <> jsMainCall (not exportRuntime) name
+            let contents = fromText (pack s')
 
             case yfsExternal settings of
                 Nothing ->
@@ -388,21 +388,28 @@
     qRunIO writeYesodFay
     [|
         liftIO (compileFayFile (mkfp name) config
-                { configTypecheck = False
+                { configTypecheck = typecheckDevel
                 , configExportRuntime = exportRuntime
                 , configPackages = packages
 #if MIN_VERSION_fay(0, 19, 0)
                 , configSourceMap = True
 #endif
+                , configPrettyPrint = True
                 })
                 >>= \eres -> do
         (case eres of
-              Left e -> error $ "Unable to compile Fay module \"" ++ name ++ "\": " ++ show e
+              Left e -> throwFayError name e
               Right s -> do
                 maybeRequireJQuery needJQuery
                 $(requireFayRuntime settings)
-                toWidget (const $ Javascript $ fromText (pack s) <> jsMainCall (not exportRuntime) name))|]
+                toWidget (const $ Javascript $ fromText (pack s)))|]
   where
     name = yfsModuleName settings
     exportRuntime = isNothing (yfsSeparateRuntime settings)
     packages = yfsPackages settings
+    typecheckDevel = yfsTypecheckDevel settings
+
+-- | Throw a fay error.
+throwFayError :: String -> CompileError -> error
+throwFayError name e =
+  error $ "Unable to compile Fay module \"" ++ name ++ "\":\n\n" ++ showCompileError e
diff --git a/yesod-fay.cabal b/yesod-fay.cabal
--- a/yesod-fay.cabal
+++ b/yesod-fay.cabal
@@ -2,7 +2,7 @@
 -- documentation, see http://haskell.org/cabal/users-guide/
 
 name:                yesod-fay
-version:             0.5.0.1
+version:             0.5.1
 synopsis:            Utilities for using the Fay Haskell-to-JS compiler with Yesod.
 description:         For initial discussion, see <http://www.yesodweb.com/blog/2012/10/yesod-fay-js>. This is a work-in-progress.
 homepage:            https://github.com/fpco/yesod-fay
@@ -20,6 +20,7 @@
   other-modules:       Yesod.Fay.Data
   build-depends:       base >= 4 && < 5
                      , fay  >= 0.16
+                     , fay-text
                      , transformers >= 0.2
                      , aeson >= 0.6
                      , bytestring >= 0.9
