@@ -50,9 +50,9 @@ build flags rootFile =
50 (extension, code) <-
50 (extension, code) <-
51 if Flag.only_js flags
51 if Flag.only_js flags
52 then do putStr "Generating JavaScript ... "
52 then do putStr "Generating JavaScript ... "
53− return ("js", js)
53+ makeJs js
54 else do putStr "Generating HTML ... "
54 else do putStr "Generating HTML ... "
55− return (makeHtml js moduleName)
55+ makeHtml js moduleName
57 let targetFile = Utils.buildPath flags rootFile extension
57 let targetFile = Utils.buildPath flags rootFile extension
58 createDirectoryIfMissing True (takeDirectory targetFile)
58 createDirectoryIfMissing True (takeDirectory targetFile)
@@ -65,9 +65,25 @@ build flags rootFile =
65 src <- BS.readFile filePath
65 src <- BS.readFile filePath
66 return (BS.append src js)
66 return (BS.append src js)
68− sources js = map Html.Link (Flag.scripts flags) ++ [ Html.Source js ]
68+ getRuntime :: IO Html.JSSource
70+ let runtimePath = Maybe.fromMaybe Path.runtime (Flag.set_runtime flags) in
71+ case Flag.bundle_runtime flags of
72+ False -> return (Html.Link runtimePath)
73+ True -> Html.Source `fmap` BS.readFile runtimePath
75+ makeJs :: BS.ByteString -> IO (String, BS.ByteString)
77+ do runtime <- getRuntime
79+ Html.Link _ -> return ("js", js)
80+ Html.Source rts -> return ("js", BS.append rts js)
82+ makeHtml :: BS.ByteString -> String -> IO (String, BS.ByteString)
83+ makeHtml js moduleName =
84+ do runtime <- getRuntime
70− makeHtml js moduleName = ("html", BS.pack $ renderHtml html)
85+ return ("html", BS.pack $ renderHtml (html runtime))
72− rtsPath = Maybe.fromMaybe Path.runtime (Flag.set_runtime flags)
87+ sources js = map Html.Link (Flag.scripts flags) ++ [ Html.Source js ]
73− html = Html.generate rtsPath (takeBaseName rootFile) (sources js) moduleName ""
89+ Html.generate runtime (takeBaseName rootFile) (sources js) moduleName ""