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

Nested Elm variable when using webpack2 #149

Open
zgohr opened this issue Aug 30, 2018 · 5 comments
Open

Nested Elm variable when using webpack2 #149

zgohr opened this issue Aug 30, 2018 · 5 comments

Comments

@zgohr
Copy link

zgohr commented Aug 30, 2018

I tried to reproduce this with the included webpack2 example but I couldn't get that one running.

The issue is that using webpack2 seems to nest the Elm javascript variable.

Example (working code):

var Elm = require('./Main')
Elm.Elm.Main.init({node: document.getElementById('main')});

Found this while upgrading elm-select here

@sporto
Copy link
Contributor

sporto commented Sep 3, 2018

@eeue56
Copy link
Contributor

eeue56 commented Sep 3, 2018

PRs welcome

@RaniSputnik
Copy link

Have confirmed this is also happening with WP4 and Elm 0.19.

@embryCODE
Copy link

embryCODE commented Oct 17, 2018

For those of us using es6 modules, this did the trick for me:

import { Elm } from '../elm/src/Main.elm'

Elm.Main.init({ node: document.getElementById('elm') })

As noted above, you can also do this:

import Elm from '../elm/src/Main.elm'

Elm.Elm.Main.init({ node: document.getElementById('elm') })

@tsopeh
Copy link

tsopeh commented Mar 10, 2021

import { Elm } from '../elm/src/Main.elm'

Elm.Main.init({ node: document.getElementById('elm') })

This also worked for me, using webpack 5 with Typescript and Elm 0.19.1

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 a pull request may close this issue.

6 participants