Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add failing test for most basic hello world app #36

Merged
merged 1 commit into from
Aug 15, 2016

Conversation

mbylstra
Copy link
Contributor

The getBaseDir function fails for main elm files that do not have an explicit module statement in the first line, such as the most basic possible hello world program.

The failing test results in the following error being thrown:

  1) #findAllDependencies works for a main file without an explicit module statement:
     Error: the string "/home/michael/code/bugfix/node-elm-compiler/test/fixtures/SimplestMain.elm is not a syntactically valid Elm module. Try running elm-make on it manually to figure out what the problem is." was thrown, throw an Error :)

The contents of SimplestMain.elm is

import Html

main =
    Html.text "Hello, World!"

This is clearly a valid Elm program, and running elm-make on it manually will succeed.

I arrived at this issue by following the source from elm-webpack-loader.
https://github.com/rtfeldman/elm-webpack-loader/blob/555334261b1263f2cc43e14b0b708b80774d84b0/index.js#L45, calls findAllDependencies from "node-elm-compiler": "4.1.1", and does not specific the baseDir argument. Thus, findAllDependencies tries to figure out the baseDir but fails on the the hello world program as it expects a first line containing "module".

The follow on effect when used with elm-webpack-loader is that the program will compile the first time successfully, but any changes to dependent files are not picked up by the watch functionality of webpack.

I'm not sure if the problem should be solved in elm-webpack-loader (should it be passing a baseDir argument?).

This might be the problem that OP is seeing in elm-webpack-starter: elm-community/elm-webpack-starter#27

the `getBaseDir` function fails for main elm files that do not have
an explicit module statement in the first line, such as the
most basic possible hello world program.
@mbylstra
Copy link
Contributor Author

I can confirm that simply adding module Main exposing (..) to the top of my Main.elm file solves the webpack reload issues I was having. It's a workaround for the time being.

@rtfeldman
Copy link
Owner

Thanks!

@rtfeldman rtfeldman merged commit ab49ed6 into rtfeldman:master Aug 15, 2016
@rtfeldman
Copy link
Owner

@mbylstra Fixed and published as 4.1.2. Thanks for the test! 😸

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants