question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Nested `Elm` variable when using webpack2

See original GitHub issue

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

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
embryCODEcommented, 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') })
0reactions
tsopehcommented, 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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues · elm-community/elm-webpack-loader - GitHub
Contribute to elm-community/elm-webpack-loader development by creating an account on GitHub. ... Nested Elm variable when using webpack2.
Read more >
elm-webpack-loader - Bountysource
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: ...
Read more >
Configuring an Elm App with Environment Variables via ...
So the first step is to get webpack to pick up the config we need from the environment. We'll use the dotenv npm...
Read more >
Elm FAQ
Which special type variables are there, and how do they work? How can I change the value of a field in a record?...
Read more >
Learn - Elm Discourse
Topic Replies Views Activity Extensible ECS data structure 23 602 April 19, 2021 Nice way to pass no data through port? 2 408 April 18,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found