on master help sign in
Remove minification from compiler.
66c288eEvan Czaplicki
Elm.cabal−2
@@ -87,7 +87,6 @@ Library
87 containers >= 0.3,
87 containers >= 0.3,
88 directory,
88 directory,
89 filepath,
89 filepath,
90− hjsmin,
91 indents,
90 indents,
92 language-ecmascript,
91 language-ecmascript,
93 mtl >= 2,
92 mtl >= 2,
@@ -157,7 +156,6 @@ Executable elm
157 containers >= 0.3,
156 containers >= 0.3,
158 directory,
157 directory,
159 filepath,
158 filepath,
160− hjsmin,
161 indents,
159 indents,
162 language-ecmascript,
160 language-ecmascript,
163 mtl >= 2,
161 mtl >= 2,
compiler/Compiler.hs+5−13
@@ -13,9 +13,7 @@ import System.FilePath
13import System.IO
13import System.IO
14import GHC.Conc
14import GHC.Conc
15
15
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
21
19
@@ -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
30
28
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
45− , minify :: Bool
46 , cache_dir :: FilePath
43 , cache_dir :: FilePath
47 , build_dir :: FilePath
44 , build_dir :: FilePath
48 }
45 }
@@ -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."
67− , minify = False
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 "")
193
188
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)
204
199
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 ]
209
201
210
202
211buildFiles :: Flags -> Int -> Interfaces -> String -> [FilePath] -> IO (String, Interfaces)
203buildFiles :: Flags -> Int -> Interfaces -> String -> [FilePath] -> IO (String, Interfaces)
compiler/Generate/Html.hs+3−8
@@ -2,7 +2,6 @@
2module Generate.Html
2module Generate.Html
3 (generateHtml,
3 (generateHtml,
4 createHtml,
4 createHtml,
5− JSStyle (..),
6 JSSource (..)
5 JSSource (..)
7 ) where
6 ) where
8
7
@@ -11,25 +10,21 @@ import qualified Text.Blaze.Html5 as H
11import Text.Blaze.Html5 ((!))
10import Text.Blaze.Html5 ((!))
12import qualified Text.Blaze.Html5.Attributes as A
11import qualified Text.Blaze.Html5.Attributes as A
13
12
14−import Text.Jasmine (minify)
15import qualified Data.ByteString.Lazy.Char8 as BS
13import qualified Data.ByteString.Lazy.Char8 as BS
16
14
17import Initialize (buildFromSource)
15import Initialize (buildFromSource)
18import Generate.JavaScript
16import Generate.JavaScript
19import Generate.Noscript
17import Generate.Noscript
20
18
21−data JSStyle = Minified | Readable
22−data JSSource = Link String | Source JSStyle BS.ByteString
19+data JSSource = Link String | Source BS.ByteString
23
20
24makeScript :: JSSource -> H.Html
21makeScript :: JSSource -> H.Html
25makeScript source =
22makeScript source =
26 case source of
23 case source of
27 Link src -> H.script ! A.type_ "text/javascript" ! A.src (H.toValue src) $ ""
24 Link src -> H.script ! A.type_ "text/javascript" ! A.src (H.toValue src) $ ""
28− Source style src ->
25+ Source src ->
29 H.script ! A.type_ "text/javascript" $
26 H.script ! A.type_ "text/javascript" $
30− preEscapedToMarkup $ BS.unpack $ case style of
27+ preEscapedToMarkup $ BS.unpack src
31− Minified -> minify src
32− Readable -> src
33
28
34-- |This function compiles Elm code into simple HTML.
29-- |This function compiles Elm code into simple HTML.
35--
30--