elm-lang / elm-make

A build tool for Elm projects
BSD 3-Clause "New" or "Revised" License
175 stars 45 forks source link

Feature Request: output dependencies #162

Closed qwfy closed 6 years ago

qwfy commented 7 years ago

I have several elm files in one project that has main in it, when elm-maked, each of them will produce a html suitable for viewing in browser.

When releasing the project, I need to elm-make each one of them, and copy some images, some fonts to a build folder and tar them together, typical stuff, this soon becomes tedious and need to be automated.

Currently I'm using shake to do it, like this:

#!/usr/bin/stack runghc

import Development.Shake
import Development.Shake.FilePath

main :: IO ()
main = shakeArgs shakeOptions{shakeFiles="_build"} $ do
    want [ "js/Index.js"
         , "js/Detail.js"
         ]

    "js/*.js" %> \out -> do
        let elmFile = dropDirectory1 $ out -<.> "elm"
        -- depend on all elm files, since we don't know precisely which one to depend on
        need =<< getDirectoryFiles "" ["*.elm"]
        cmd ["elm-make", elmFile, "--output", out]

However, shake needs to know the dependencies of each elm file, currently there is no way to know it (so for now I just depend on all elm files).

Will this feature be added to elm-make? so that something like elm-make --print-dependencies-only Main.elm will print:

-- Main.elm depend on these files you yourself wrote:
MyUrlParser.elm
MyRoute.elm
MyDataType.elm
-- Main.elm also depend on these, but you probably don't interested in them, since it will stay unchanged during the build:
-- elm-lang/dom
-- elm-lang/window
-- evancz/url-parser

Better, will it return structured data (like yaml or json or some other format that can be easily consumed by a program, you know, escaping and stuff) other than plain lines?

p.s. there seems no idiomatic way to build an elm project? p.s.s. please don't suggest me to just use a bash script

process-bot commented 7 years ago

Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.

evancz commented 6 years ago

Tracking in #98 with a bunch of feature requests. We will likely do a batch of improvements for editor/tooling support that will include stuff like this. Lots of folks need this for various build system choices. In the meantime, thank you for logging your scenario! It will help with that batch of work.