Coder Social home page Coder Social logo

Can't compile Elm file about elm-brunch HOT 4 CLOSED

mickeyvip avatar mickeyvip commented on May 30, 2024
Can't compile Elm file

from elm-brunch.

Comments (4)

mickeyvip avatar mickeyvip commented on May 30, 2024 1

Maybe it's worth to mention this in the docs? Or did I miss this?

from elm-brunch.

mickeyvip avatar mickeyvip commented on May 30, 2024

Found 1 of my problems - mainModules should be an array.

Now the file compiles:

image

But when requiring it - it gets only an empty object:

image

from elm-brunch.

madsflensted avatar madsflensted commented on May 30, 2024

Good to hear that you solved the compilation problem. Beware that the elm brunch plugin does not pass the generated code on down the brunch pipeline, as other to-js-transpilers do. So you will need to either include the generated js in your html use other means to get it into the main bundle.

from elm-brunch.

mickeyvip avatar mickeyvip commented on May 30, 2024

@madsflensted , thank you.

Following your advice, I have added <script src="js/main.js"></script> to the index.html:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>Simple Brunch Demo</title>
    <link rel="stylesheet" href="app.css" />
  </head>

  <body>
    <main id="root"></main>
    <h1>
      Brunch
      <small>• A simple demo</small>
    </h1>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
    <script src="libraries.js"></script>
    <script src="js/main.js"></script>
    <script src="app.js"></script>
    <script>
      require('application').init();
    </script>
  </body>
</html>

removed the const Elm = require('./elm/Main.elm'); from the application.js.

'use strict';
const Greeter = require('./greeter');
const App = {
  init() {
    console.log('App initialized.');
    const g = new Greeter();
    g.greet();
    Elm.Main.init({ node: document.getElementById('root') });
  },
};

module.exports = App;

and now it is working:

image

from elm-brunch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.