elm-make
elm-make copied to clipboard
Friendlier elm-make interface for beginners
For end users (not creating a library)
- [ ]
$ elm make
(no arguments)- [ ] if no
elm-package.json
or*.elm
, print:No elm project found, should one be created?
- create hello world
Main.elm
and defaultelm-package.json
- create hello world
- [ ] if
*.elm
exists, print:No elm-package.json was found, should one be created? (y/n)
- create
elm-package.json
- create
- [ ] if
*.elm
andelm-package.json
exist, print:Error: Please specify a main .elm file
- [ ] if no
- [x]
$ elm make Main.elm
- install dependencies found in
elm-package.json
- compile
Main.elm
, and all modules it depends on - write concatenated Html output to
index.html
- install dependencies found in
- [x]
$ elm make Main.elm -o elm.js
- write concatenated output to
elm.js
- write concatenated output to
- [x]
$ elm make Main.elm -o mypage.html
- wrap JS output in HTML and write to
mypage.html
- wrap JS output in HTML and write to
- [ ]
$ elm make Main.elm --node-js -o node-test.js
- writes JS output and adds
Elm.worker(Elm.Main);
to the end to start the app in NodeJS
- writes JS output and adds
- [ ]
$ elm make X.elm --node-js -o node.html
- Error: output file must end in .js when
--node-js
is used.
- Error: output file must end in .js when
- [x]
$ elm make X.elm -o page.htm
- Error: output file must end in either .js or .html
For library creators
TODO
The above is my suggestion for how elm make
can be easier for beginners. Please add your comments, especially about the part for library creators (which I have no experience with). Once there is agreement, we can start the implementation.
I am going to try to do this in the next couple days. I like it. I think we can combine the --node-js
and --js
flags into one thing, but otherwise I think this is way nicer!
Feedback based on the Sublime plugin:
- I save the main file in
elm-package.json
under asublime-build.main
key. It's necessary to be able to compile a given project from another file. It also seems necessary to auto-build arbitrary projects. - Our output path would be inferred as
build/Main.html
instead ofindex.html
. It's not as pretty but prevents accidentally blowing away a separate compilation.
I can't understand either of these points. Can you move this to its own issue and describe your scenario more completely? I don't know how sublime works, I don't know what you are asking for or how it relates to any of the very concrete suggestions made in this thread.
The latter point is more concrete:
write concatenated output to index.html
The default we use is build/Main.html
. If you then run elm make Counter.elm
it wouldn't blow away your previous output.
The former point might belong in a separate thread. It's difficult for us to infer what file to build. It seems like a main
key in elm-package.json
would not only benefit tooling but concepts like an auto-building gallery repo. I brought it up because it's relevant to the proposed interface.
It seems like a main key in elm-package.json
I.e. elm make
would check for main
in elm-package.json
and elm make Counter.elm
would override that key.
Please open another issue.
@evancz I've changed my mind regarding the --js
and --html
. I think having --html
, --js
and --node-js
is too much, especially since they cannot be used at the same time.
Instead I think we should:
- make it clear in the
--help
message that HTML, JS and NodeJS outputs are supported - keep the current situation where the output filename determines the output type but add an error if the user uses any extension except
.js
or.html
. This will prevent the confusion when using.htm
or something else. - add a
--node-js
option which gives an error if the output filename does not end in.js
.
Let's talk about this at the meeting later.
@seliopou is more used to being able to get everything compiling without something like elm-package.json and suggested we look at OCaml's Oasis for inspiration on how to support that usage in a nice way.
@laszlopandy, if you get a chance, I'd be curious if you think we can bring any ideas over.
That link makes it look like a cabal-type thing. Is there any info about specifically what the good parts are?
On Thursday, September 24, 2015, Evan Czaplicki [email protected] wrote:
@laszlopandy https://github.com/laszlopandy, if you get a chance, I'd be curious if you think we can bring any ideas over.
— Reply to this email directly or view it on GitHub https://github.com/elm-lang/elm-make/issues/23#issuecomment-143057347.
@laszlopandy I noticed under For Library Authors there were no suggestions but I believe I have one from my own experience today. It looks like if no modules are specified for exposed-modules
that elm-make
will not build anything and just reports "Success! Compiled 0 modules.". I would suggest that a simple hint should be displayed at this point that says something along the lines of "If you want to make a library you need to list one or more modules as exposed-modules in elm-package.json".