Undefined module when calling Elm from js


Hi, I’m “porting” a module from 0.18 to 0.19 and I’m having a problem that most probably is a distraction, but I can’t spot what I’m doing wrong.

module SignUp exposing (main)
import Browser exposing (element)

main : Program () Model Msg
main =
      init = init,
      view = view,
      update = update,
      subscriptions = \_ -> Sub.none

(clearly I omitted the import for all the functions that Browser.element receives)

import Elm from '../SignUp'

document.addEventListener('DOMContentLoaded', () => {
  var app = Elm.SignUp.init({
    node: document.getElementById('signin-form'),
    flags: {}

I don’t think it’s relevant but the app is Rails + Webpack

TypeError: _SignUp__WEBPACK_IMPORTED_MODULE_0___default.a.SignUp is undefined

Before 0.19 this was very similar:

import Elm from '../SignUp'

document.addEventListener('DOMContentLoaded', () => {
  const target = document.getElementById('signin-form');
  var SignUp = Elm.Main.embed(target);

I noted that I wasn’t defining a module inside my SignUp.elm module which was quite weird, but everything was actually working.
Any idea?


I think given the way the compiler generates the final export you need to do

import { Elm } from ‘../SignUp’


goodness… how did you get this information?
Thank you so much, works like a charm.


This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.