ccapndave / fuse-box-elm-plugin

A fuse-box plugin to transpile and bundle Elm
Other
3 stars 2 forks source link

Occasional ENOENT error #5

Open chrstntdd opened 6 years ago

chrstntdd commented 6 years ago

I believe this has to be related to hot module replacement implementation for this plugin since this error will only be thrown during a change to my source files. Not a huge bug really, I can usually get around it by restarting fuse, clearing out .fusebox, removing node_modules and doing a fresh install of all my dependencies, or some combination of those three.

events.js:136
      throw er; // Unhandled 'error' event
      ^

Error: spawn /Users/christian.todd/Development/portfolio/node_modules/elm/Elm-Platform/0.18.0/.cabal-sandbox/bin/elm-make ENOENT
    at _errnoException (util.js:999:13)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:201:19)
    at onErrorNT (internal/child_process.js:389:16)
    at process._tickCallback (internal/process/next_tick.js:152:19)
    at Function.Module.runMain (module.js:703:11)
    at startup (bootstrap_node.js:194:16)
    at bootstrap_node.js:618:3
Failed to compile Elm.

In my fuse.js file, I have this for my development builds:

task('dev-build', async context => {
  const fuse = context.getMainConfig();
  const serverOpts = { root: false };

  fuse.dev(serverOpts, server => {
    const app = server.httpServer.app;
    app.use(express.static(outDir));
    app.get('*', (req, res) => {
      res.sendFile(join(outDir, '/index.html'));
    });
  });

  fuse
    .bundle('app')
    .hmr({ reload: true })
    .watch()
    .instructions('> index.js');

  await fuse.run();
});
ccapndave commented 6 years ago

Weird - I haven't seen that one before. I don't use { reload: true } in my hmr config. I wonder if that is affecting things somehow?

chrstntdd commented 6 years ago

That must be it. I notice too that with this config, hitting save will trigger a recompile and will on occasionally result in a log like this:

Success! Compiled 1 module.
Successfully generated /var/folders/jg/x0pw1f5j3lsdctc4j_pyxf6r0000gn/T/tmp-42706mmMbZteuZoFi.js
Failed to compile Elm.

In the browser I also get this warning as well, so I think it must be due to HMR:

uncaught exception: Package not found fusebox-hot-reload

Maybe a race condition where the entire bundle isn't receiving fusebox-hot-reload?