@@ -13,9 +13,7 @@ import System.FilePath
13import System.IO
13import System.IO
14import GHC.Conc
14import GHC.Conc
16−import qualified Text.Blaze.Html.Renderer.Pretty as Pretty
16+import Text.Blaze.Html.Renderer.Pretty (renderHtml)
17−import qualified Text.Blaze.Html.Renderer.String as Normal
18−import qualified Text.Jasmine as JS
19import qualified Data.ByteString.Lazy.Char8 as BS
17import qualified Data.ByteString.Lazy.Char8 as BS
20import qualified Data.ByteString.Lazy as L
18import qualified Data.ByteString.Lazy as L
@@ -25,7 +23,7 @@ import SourceSyntax.Module
25import Parse.Module (getModuleName)
23import Parse.Module (getModuleName)
26import Initialize (buildFromSource, getSortedDependencies)
24import Initialize (buildFromSource, getSortedDependencies)
27import Generate.JavaScript (jsModule)
25import Generate.JavaScript (jsModule)
28−import Generate.Html (createHtml, JSStyle(..), JSSource(..))
26+import Generate.Html (createHtml, JSSource(..))
29import Paths_Elm
27import Paths_Elm
31import SourceSyntax.PrettyPrint (pretty, variable)
29import SourceSyntax.PrettyPrint (pretty, variable)
@@ -42,7 +40,6 @@ data Flags =
42 , print_program :: Bool
40 , print_program :: Bool
43 , scripts :: [FilePath]
41 , scripts :: [FilePath]
44 , no_prelude :: Bool
42 , no_prelude :: Bool
46 , cache_dir :: FilePath
43 , cache_dir :: FilePath
47 , build_dir :: FilePath
44 , build_dir :: FilePath
@@ -64,8 +61,6 @@ flags = Flags
64 &= help "Load JavaScript files in generated HTML. Files will be included in the given order."
61 &= help "Load JavaScript files in generated HTML. Files will be included in the given order."
65 , no_prelude = False
62 , no_prelude = False
66 &= help "Do not import Prelude by default, used only when compiling standard libraries."
63 &= help "Do not import Prelude by default, used only when compiling standard libraries."
68− &= help "Minify generated JavaScript and HTML"
69 , cache_dir = "cache" &= typFile
64 , cache_dir = "cache" &= typFile
70 &= help "Directory for files cached to make builds faster. Defaults to cache/ directory."
65 &= help "Directory for files cached to make builds faster. Defaults to cache/ directory."
71 , build_dir = "build" &= typFile
66 , build_dir = "build" &= typFile
@@ -184,11 +179,11 @@ build flags rootFile = do
184 (extension, code) <- case only_js flags of
179 (extension, code) <- case only_js flags of
185 True -> do
180 True -> do
186 putStr "Generating JavaScript ... "
181 putStr "Generating JavaScript ... "
187− return ("js", genJs js)
182+ return ("js", js)
188 False -> do
183 False -> do
189 putStr "Generating HTML ... "
184 putStr "Generating HTML ... "
190 rtsPath <- getRuntime flags
185 rtsPath <- getRuntime flags
191− return ("html", BS.pack . genHtml $
186+ return ("html", BS.pack . renderHtml $
192 createHtml rtsPath (takeBaseName rootFile) (sources js) moduleName "")
187 createHtml rtsPath (takeBaseName rootFile) (sources js) moduleName "")
194 let targetFile = buildPath flags rootFile extension
189 let targetFile = buildPath flags rootFile extension
@@ -202,10 +197,7 @@ build flags rootFile = do
202 do src <- BS.readFile (elmo flags filePath)
197 do src <- BS.readFile (elmo flags filePath)
203 return (BS.append src js)
198 return (BS.append src js)
205− genHtml = if minify flags then Normal.renderHtml else Pretty.renderHtml
206− genJs = if minify flags then JS.minify else id
207− sources js = map Link (scripts flags) ++
200+ sources js = map Link (scripts flags) ++ [ Source js ]
208− [ Source (if minify flags then Minified else Readable) js ]
211buildFiles :: Flags -> Int -> Interfaces -> String -> [FilePath] -> IO (String, Interfaces)
203buildFiles :: Flags -> Int -> Interfaces -> String -> [FilePath] -> IO (String, Interfaces)