elm-webpack-loader icon indicating copy to clipboard operation
elm-webpack-loader copied to clipboard

elm-webpack-loader appears to be trying to use file without main as an entrypoint

Open alex-tan opened this issue 4 years ago • 3 comments

I'm running into an issue where I have a single entry for my webpack config entry: "./src/index.ts". That file imports a single Elm app import { Elm } from "./App.elm"; but for some reason when I upgraded to "elm-webpack-loader": "^8.0.0" from the elm-webpack-starter I've started seeing it attempt to compile an additional file in my src/ directory called src/Events.elm. This causes the elm compiler to complain with

Note: Adding a `main` value can be as brief as adding something like this:

import Html

main =
  Html.text "Hello!"

Which is strange because there are other elm files in the root of the src directory that it doesn't seem to care about.

I attempted to debug the issue by specifying the files option to be ['src/App.elm'] which resolves the issue but causes each save to trigger 3 compilations in the terminal.

If anyone has any hunches about why this might be happening it would be much appreciated.

alex-tan avatar May 16 '21 15:05 alex-tan

does that file have anything named main - even an in-line let statement

simonh1000 avatar May 18 '21 08:05 simonh1000

No, nothing called main in that file. I ended up resolving the issue by moving the file to a nested directory, though didn't figure out what was causing the issue.

alex-tan avatar May 18 '21 09:05 alex-tan

In my case, this line

import { getDimensions } from "../../../shared/Runtime/runtime.js";

was leading webpack to attempt to compile ../../../shared/Runtime/Runtime.elm and this file does not have main in it

This elm file was imported by by Elm entry point but not sure whether that matters - comment the above line out, or renaming to RuntimeSOMETHING.elm seems to be a workaround

simonh1000 avatar Feb 25 '22 17:02 simonh1000