madsflensted / elm-brunch

Brunch plugin to compile Elm code
MIT License
74 stars 31 forks source link

Problem with initial file compilation on Windows #16

Open rudolfb opened 8 years ago

rudolfb commented 8 years ago

Problem

On windows it seems as if, after cloning a repo, the elm files are not compiled. Only after changing the contents of every elm file, then saving each file, does elm-brunch recognize the change in the file and compiles the elm file to a js file.

Mac OSX and Linux (Ubuntu 15) work fine. The problem only happens on Windows. I have reproduced this on two different Windows workstations.

Repo: https://github.com/svard/hello_phoenix

The problem with reproducing this issue with this repo is, the project is a phoenix/Elixir project with Elm as the frontend rendering tool. If you need to reproduce the problem with the above repo, it is relatively straightforward:

Install chocolatey

choco install erlang -y
choco install elixir -y

In the projects root folder:

mix deps.get
npm install
mix phoenix.server

The Elm file is in the folder

web\static\elm

The compiled js file is written to the folder

priv\static\js

Hope this is enough information regarding this issue.

Regards

Rudolf Bargholz

Information

0.4.4

2.5.2

5.9.0

exports.config = {
  // See http://brunch.io/#documentation for docs.
  files: {
    javascripts: {
      joinTo: "js/app.js"

      // To use a separate vendor.js bundle, specify two files path
      // https://github.com/brunch/brunch/blob/stable/docs/config.md#files
      // joinTo: {
      //  "js/app.js": /^(web\/static\/js)/,
      //  "js/vendor.js": /^(web\/static\/vendor)|(deps)/
      // }
      //
      // To change the order of concatenation of files, explicitly mention here
      // https://github.com/brunch/brunch/tree/master/docs#concatenation
      // order: {
      //   before: [
      //     "web/static/vendor/js/jquery-2.1.1.js",
      //     "web/static/vendor/js/bootstrap.min.js"
      //   ]
      // }
    },
    stylesheets: {
      joinTo: "css/app.css"
    },
    templates: {
      joinTo: "js/app.js"
    }
  },

  conventions: {
    // This option sets where we should place non-css and non-js assets in.
    // By default, we set this to "/web/static/assets". Files in this directory
    // will be copied to `paths.public`, which is "priv/static" by default.
    assets: /^(web\/static\/assets)/
  },

  // Phoenix paths configuration
  paths: {
    // Dependencies and current project directories to watch
    watched: [
      "web/static",
      "test/static"
    ],

    // Where to compile files to
    public: "priv/static"
  },

  // Configure your plugins
  plugins: {
    babel: {
      // Do not use ES6 compiler in vendor code
      ignore: [/web\/static\/vendor/]
    },
    elmBrunch: {
      mainModules: ["web/static/elm/Chat.elm"]
    }
  },

  modules: {
    autoRequire: {
      "js/app.js": ["web/static/js/app"]
    }
  },

  npm: {
    enabled: true,
    // Whitelist the npm deps to be pulled in as front-end assets.
    // All other deps in package.json will be excluded from the bundle.
    whitelist: ["phoenix", "phoenix_html"]
  }
};
{

  "version": "1.0.0",
  "summary": "helpful summary of your project, less than 80 characters",
  "repository": "https://github.com/user/project.git",
  "license": "BSD3",
  "source-directories": [
    "web/static/elm"
  ],
  "exposed-modules": [],
  "dependencies": {
    "elm-lang/core": "3.0.0 <= v < 4.0.0",
    "evancz/elm-effects": "2.0.1 <= v < 3.0.0",
    "evancz/elm-html": "4.0.2 <= v < 5.0.0",
    "evancz/start-app": "2.0.2 <= v < 3.0.0",
    "svard/elm-phoenix": "2.0.0 <= v < 3.0.0"
  },
  "elm-version": "0.16.0 <= v < 0.17.0"
}

/web/static/elm/

Windows 10

madsflensted commented 8 years ago

I don't have a platform to reproduce this error - but I suspect it relates to the "mainModules" setting - and that elm-brunch does not recognize the main module due to the non-windows path spec. All non-main modules are skipped on first alert from brunch - since brunch at startup will send events for all files.

maybe you can try to change brunch config to:

   mainModules: ["web\\static\\elm\\Chat.elm"]

and see what that does?

You could also run brunc with --debug and see if files are detected and processed.

rudolfb commented 8 years ago

Hi Mads,

Sorry for the late reply. Easter belonged to my daughter.

Changed the brunch-config.js to

    elmBrunch: {
      mainModules: ["web\\static\\elm\\Chat.elm"]
    }

and the chat.js file is now automatically created on running

mix phoenix.server

So this seems to resolve my problem on Windows. Thanks. Now I just need to see if this works on Linux and Mac.

Regards

Rudolf

rudolfb commented 8 years ago

Hi Mads,

Ok, tested on Linux, and changing the path to

    elmBrunch: {
      mainModules: ["web\\static\\elm\\Chat.elm"]
    }

failed to compile the Chat.elm to chat.js. Is this something you would have to implement in elm-brunch, to convert the path seperators from / to \\ on Windows?

Regards

Rudolf

madsflensted commented 8 years ago

Ok, Good to hear.

The whole plugin is due for an overhaul based on the new plugin structure brunch uses, so a general fix for this Windows / Linux path issue would go with that release. On Mar 29, 2016 17:26, "Rudolf Bargholz" notifications@github.com wrote:

Hi Mads,

Ok, tested on Linux, and changing the path to

elmBrunch: {
  mainModules: ["web\\static\\elm\\Chat.elm"]
}

failed to compile the Chat.elm to chat.js. Is this something you would have to implement in elm-brunch, to convert the path seperators from / to \ on Windows?

Regards

Rudolf

— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/madsflensted/elm-brunch/issues/16#issuecomment-202952090