madsflensted / elm-brunch

Brunch plugin to compile Elm code
MIT License
74 stars 31 forks source link

Failing elm-make on 0.11.0 for a config that works on 0.10.0 #42

Closed savish closed 6 years ago

savish commented 6 years ago

Problem

Using the same brunch configuration for an app running phoenix+elm, with one version using elm-brunch 0.10.0 and the other using 0.11.0, the following error always occurs on 0.11.0:

$ mix phx.server
...
Elm compile: Main.elm, in elm, to ../vendor/main.js
...
elm-make: Main.elm: openFile: does not exist (No such file or directory)

There is no error on the 0.10.0 version. However, the output is slightly different. The elm-compile line looks like:

Elm compile: src/Main.elm, in elm, to ../vendor/main.js

It seems as though the 0.11.0 version cannot locate the Main.elm file in the src folder. The relevant section of brunch-config.js is given below, as well as the elm files, relative to the root (the assets folder).

Possible cause

It seems as though this issue is related to a slight change in the index.js file, where the function call to elmCompile now receives a path.basename(src) as opposed to just the src, even if the independentModules flag is false.

Information

brunch-config.js (same for the 0.10.0 and 0.11.0 versions)

elmBrunch: {
  elmFolder: "elm",
  mainModules: ["src/Main.elm"],
  outputFolder: "../vendor"
}

File layout:

assets
  elm
    src
      Main.elm
    elm-package.json
  brunch-config.js
madsflensted commented 6 years ago

Thank you for reporting this and the detailed information.

@neildaemond can you have a look at this? We will need to expand test to cover this regression.

neildaemond commented 6 years ago

Hi, yes thank you for the amount of detail. You are completely right, I can see how this can fail - I just didn't think of elm project with that structure. I'll try rectify that now.

neildaemond commented 6 years ago

fixed in https://github.com/madsflensted/elm-brunch/pull/43

madsflensted commented 6 years ago

Fix published as 0.11.1 @savish can you give it a try?

savish commented 6 years ago

Hey! Works as expected. Thank you for the quick fix!