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

Race condition in brunch compile #26

Open
OvermindDL1 opened this issue Jul 29, 2016 · 2 comments
Open

Race condition in brunch compile #26

OvermindDL1 opened this issue Jul 29, 2016 · 2 comments

Comments

@OvermindDL1
Copy link

OvermindDL1 commented Jul 29, 2016

I am having the elm-brunch plugin compile a variety of main apps into a single file, which is output to a brunch watched directory of other javascript, which then all gets compiled into one single javascript file. However brunch does not seem to pick up on Elm changes immediately as it seems to start compiling while Elm does and Elm finishes writing 'after' Brunch has already started compiling the files, so I have to save a file twice with ten seconds or so between them to have it compile twice.

Information

  • [0.6.0 ] elm-brunch version
  • [ 2.8.2] brunch version
  • [] nodejs version
  • content of brunch-config.js: Huge, but relevant parts are:
  plugins: {
    babel: {
      presets: ['es2015'],
      plugins: ["transform-object-rest-spread"],
      // Do not use ES6 compiler in vendor code
      ignore: [/web\/static\/vendor/],
      compact: false
    },
    elmBrunch: {
      elmFolder: '.',
      mainModules: [
        'web/elm/MessengerApp.elm',
        'web/elm/ExampleElmApp.elm'
      ],
      outputFolder: 'web/static/js',
      outputFile: 'elm.js',
      makeParameters: ['--warn']
    }
  },
  modules: {
    autoRequire: {
      "js/app.js": ["web/static/js/app"]
    }
  },
  paths: {
    watched: [
      "web/elm",
      "web/static",
      "test/static"
    ],

    public: "priv/static"
  },
  files: {
    javascripts: {
      joinTo: "js/app.js",
    },
    templates: {
      joinTo: "js/app.js"
    }
  },
  • content of elm-package.json:
{
  "version": "0.1.0",
  "summary": "Test",
  "repository": "https://github.com/user/project.git",
  "license": "BSD3",
  "source-directories": [
    "web/elm"
  ],
  "exposed-modules": [],
  "dependencies": {
    "elm-lang/core": "4.0.2 <= v < 5.0.0",
    "elm-lang/html": "1.1.0 <= v < 2.0.0",
  },
  "elm-version": "0.17.1 <= v < 0.18.0",
  • file layout for your elm files relative to root of project: elm-package.json is in the project root, elm files are in web/elm
  • Operating System - Windows 10 (it could very well be its filesystem at fault, and if so then it should sleep and test until it is finished saving until it lets brunch compile it all together).
@madsflensted
Copy link
Owner

Yes there have been a couple of different issues related to this. I am not sure they will ever be a perfect solution to this, but one way that might work is to wait (async) for the elm to finish, then read the resulting js file and pass it on from the compilation step, instead of relying on brunch reading the output of elm compiler.

@OvermindDL1
Copy link
Author

Ah, so setting it up as a brunch compiler instead of a pre-processing step, that might work yeah. Just remember that at least on Windows the file it unreadable for up to a few seconds after elm finishes while windows finishes writing it to disk. This might be the main cause of brunch not picking up the new changes properly actually, but if the elm compiler could output to a file and to stdout (or just to stdout and you write the file out) then that should sidestep the issue well.

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

No branches or pull requests

2 participants