Tony Onodi
1 min readOct 2, 2016

--

This no longer works without some tweaking. I’m not sure if it’s because of changes to Elm, Electron or both — I’m probably pointing the finger at Elm 0.17, but that’s just a guess.

The solution to this is to remove the script tag that imports the compiled elm code form index.html and add

const Elm = require(‘./elm.js’);

to the top of ports.js. You also need to change

let feldspar = Elm.embed(Elm.Main, container)

to

let feldspar = Elm.Main.embed(container);

at the bottom of ports.js.

If you just followed the steps in the tutorial it will tell you Elm isn’t defined. This is because the compiled Elm code no longer throws the Elm object into the global namespace in this environment; it detects module support and leans on the require API instead.

Sorry for the lengthy post but this stopped me in my tracks following what was otherwise a very clear and straightforward walkthrough (great job with this post!) so hopefully this will help someone else who finds themselves in the same situation.

--

--

Tony Onodi

Knocking tweets into the void on a semi-regular basis.