From 66c288e4bac114c430d53b34d80ccba2dd166ab5 Mon Sep 17 00:00:00 2001 From: Evan Czaplicki Date: Sat, 28 Sep 2013 15:36:02 -0400 Subject: [PATCH] Remove minification from compiler. Unix philosophy and all that. --- Elm.cabal | 2 -- compiler/Compiler.hs | 18 +++++------------- compiler/Generate/Html.hs | 11 +++-------- 3 files changed, 8 insertions(+), 23 deletions(-) diff --git a/Elm.cabal b/Elm.cabal index f88ce03..bf72799 100644 --- a/Elm.cabal +++ b/Elm.cabal @@ -87,7 +87,6 @@ Library containers >= 0.3, directory, filepath, - hjsmin, indents, language-ecmascript, mtl >= 2, @@ -157,7 +156,6 @@ Executable elm containers >= 0.3, directory, filepath, - hjsmin, indents, language-ecmascript, mtl >= 2, diff --git a/compiler/Compiler.hs b/compiler/Compiler.hs index 0d933c9..b5c878e 100644 --- a/compiler/Compiler.hs +++ b/compiler/Compiler.hs @@ -13,9 +13,7 @@ import System.FilePath import System.IO import GHC.Conc -import qualified Text.Blaze.Html.Renderer.Pretty as Pretty -import qualified Text.Blaze.Html.Renderer.String as Normal -import qualified Text.Jasmine as JS +import Text.Blaze.Html.Renderer.Pretty (renderHtml) import qualified Data.ByteString.Lazy.Char8 as BS import qualified Data.ByteString.Lazy as L @@ -25,7 +23,7 @@ import SourceSyntax.Module import Parse.Module (getModuleName) import Initialize (buildFromSource, getSortedDependencies) import Generate.JavaScript (jsModule) -import Generate.Html (createHtml, JSStyle(..), JSSource(..)) +import Generate.Html (createHtml, JSSource(..)) import Paths_Elm import SourceSyntax.PrettyPrint (pretty, variable) @@ -42,7 +40,6 @@ data Flags = , print_program :: Bool , scripts :: [FilePath] , no_prelude :: Bool - , minify :: Bool , cache_dir :: FilePath , build_dir :: FilePath } @@ -64,8 +61,6 @@ flags = Flags &= help "Load JavaScript files in generated HTML. Files will be included in the given order." , no_prelude = False &= help "Do not import Prelude by default, used only when compiling standard libraries." - , minify = False - &= help "Minify generated JavaScript and HTML" , cache_dir = "cache" &= typFile &= help "Directory for files cached to make builds faster. Defaults to cache/ directory." , build_dir = "build" &= typFile @@ -184,11 +179,11 @@ build flags rootFile = do (extension, code) <- case only_js flags of True -> do putStr "Generating JavaScript ... " - return ("js", genJs js) + return ("js", js) False -> do putStr "Generating HTML ... " rtsPath <- getRuntime flags - return ("html", BS.pack . genHtml $ + return ("html", BS.pack . renderHtml $ createHtml rtsPath (takeBaseName rootFile) (sources js) moduleName "") let targetFile = buildPath flags rootFile extension @@ -202,10 +197,7 @@ build flags rootFile = do do src <- BS.readFile (elmo flags filePath) return (BS.append src js) - genHtml = if minify flags then Normal.renderHtml else Pretty.renderHtml - genJs = if minify flags then JS.minify else id - sources js = map Link (scripts flags) ++ - [ Source (if minify flags then Minified else Readable) js ] + sources js = map Link (scripts flags) ++ [ Source js ] buildFiles :: Flags -> Int -> Interfaces -> String -> [FilePath] -> IO (String, Interfaces) diff --git a/compiler/Generate/Html.hs b/compiler/Generate/Html.hs index edb85c1..33ea2b6 100644 --- a/compiler/Generate/Html.hs +++ b/compiler/Generate/Html.hs @@ -2,7 +2,6 @@ module Generate.Html (generateHtml, createHtml, - JSStyle (..), JSSource (..) ) where @@ -11,25 +10,21 @@ import qualified Text.Blaze.Html5 as H import Text.Blaze.Html5 ((!)) import qualified Text.Blaze.Html5.Attributes as A -import Text.Jasmine (minify) import qualified Data.ByteString.Lazy.Char8 as BS import Initialize (buildFromSource) import Generate.JavaScript import Generate.Noscript -data JSStyle = Minified | Readable -data JSSource = Link String | Source JSStyle BS.ByteString +data JSSource = Link String | Source BS.ByteString makeScript :: JSSource -> H.Html makeScript source = case source of Link src -> H.script ! A.type_ "text/javascript" ! A.src (H.toValue src) $ "" - Source style src -> + Source src -> H.script ! A.type_ "text/javascript" $ - preEscapedToMarkup $ BS.unpack $ case style of - Minified -> minify src - Readable -> src + preEscapedToMarkup $ BS.unpack src -- |This function compiles Elm code into simple HTML. --