elm-make icon indicating copy to clipboard operation
elm-make copied to clipboard

Friendlier elm-make interface for beginners

Open laszlopandy opened this issue 9 years ago • 12 comments

For end users (not creating a library)

  1. [ ] $ 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 default elm-package.json
    • [ ] if *.elm exists, print: No elm-package.json was found, should one be created? (y/n)
      • create elm-package.json
    • [ ] if *.elm and elm-package.json exist, print: Error: Please specify a main .elm file
  2. [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
  3. [x] $ elm make Main.elm -o elm.js
    • write concatenated output to elm.js
  4. [x] $ elm make Main.elm -o mypage.html
    • wrap JS output in HTML and write to mypage.html
  5. [ ] $ 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
  6. [ ] $ elm make X.elm --node-js -o node.html
    • Error: output file must end in .js when --node-js is used.
  7. [x] $ elm make X.elm -o page.htm
    • Error: output file must end in either .js or .html

For library creators

TODO

laszlopandy avatar Jun 19 '15 11:06 laszlopandy

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.

laszlopandy avatar Jun 19 '15 12:06 laszlopandy

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!

evancz avatar Aug 19 '15 21:08 evancz

Feedback based on the Sublime plugin:

  • I save the main file in elm-package.json under a sublime-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 of index.html. It's not as pretty but prevents accidentally blowing away a separate compilation.

texastoland avatar Aug 20 '15 01:08 texastoland

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.

evancz avatar Aug 20 '15 01:08 evancz

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.

texastoland avatar Aug 20 '15 01:08 texastoland

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.

texastoland avatar Aug 20 '15 02:08 texastoland

Please open another issue.

evancz avatar Aug 20 '15 03:08 evancz

@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.

laszlopandy avatar Aug 25 '15 09:08 laszlopandy

@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.

evancz avatar Sep 24 '15 21:09 evancz

@laszlopandy, if you get a chance, I'd be curious if you think we can bring any ideas over.

evancz avatar Sep 24 '15 21:09 evancz

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 avatar Sep 25 '15 01:09 laszlopandy

@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".

jpierson avatar Mar 12 '18 02:03 jpierson