elm-community / elm-webpack-loader

Webpack loader for the Elm programming language.
BSD 3-Clause "New" or "Revised" License
532 stars 105 forks source link

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

Open alex-tan opened 3 years ago

alex-tan commented 3 years ago

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.

simonh1000 commented 3 years ago

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

alex-tan commented 3 years ago

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.

simonh1000 commented 2 years ago

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