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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Elm + parcel serve unusable: File changes not detected after compilation error #6124

Closed
cmditch opened this issue Apr 13, 2021 · 23 comments 路 Fixed by #7326 or #7547
Closed

Elm + parcel serve unusable: File changes not detected after compilation error #6124

cmditch opened this issue Apr 13, 2021 · 23 comments 路 Fixed by #7326 or #7547

Comments

@cmditch
Copy link

cmditch commented Apr 13, 2021

馃悰 bug report

If Elm compilation fails then parcel serve/watch auto-recomplitaion mostly breaks. If the entry-point Elm file (i.e. Main.elm) is edited then recompilation will work, but if any non-entry-point Elm file is edited recompilation does not occur. Since the entry point (Main.elm) is very rarely touched in most Elm projects it makes parcel serve/watch basically unusable w/ Elm.

SSCCE here

馃帥 Configuration (.babelrc, package.json, cli command)

https://github.com/cmditch/parcel2-elm-error/blob/master/package.json

馃 Expected Behavior

Every time an Elm file is touched, regardless of the compilation state, parcel serve/watchshould recompile the project.

馃拋 Possible Solution

No idea. The watcher seems to work on all Elm files, but only when the last compilation was a success.

馃捇 Code Sample

Clone and run yarn; yarn hot in the SSCCE here and see instructions here to reproduce.

馃實 Your Environment

Software Version(s)
Parcel 2.0.0-nightly.639+059d502f
Node 12.22.0
npm/Yarn yarn 1.22.10
Operating System macOS 10.15.7

Thanks,
Coury

@cmditch
Copy link
Author

cmditch commented Apr 13, 2021

This sounds somewhat similar to what is being described here (#5660 (comment)) and was potentially fixed here (#6072), but it doesn't look like the latter has fixed the issue.

The primary difference is that the watcher breaks only after compilation error.

@neurodynamic
Copy link

I'm seeing this same behavior. Details:

  • it appears to only happen after compilation errors
  • it resolves itself if I make changes to a file that imports my Elm app (in my case, changing either my main.ts file or the index.html file that imports main.ts will resolve the issue, but changes to Elm files are not detected until I change one of those

@mischnic
Copy link
Member

Does this still happen with the latest nightly?

@neurodynamic
Copy link

@mischnic Yup; just tried it with ^2.0.0-nightly.649 and same behavior as before.

@aivchen
Copy link

aivchen commented May 6, 2021

I am experiencing the same problem. If compilation fails due to errors in scss files then recompilation is working only in case of editing entrypoint file (index.html in my case)

@obiloud
Copy link

obiloud commented May 30, 2021

Just migrated to parcel 2. I am seeing the same with ^2.0.0-nightly.688.

@arkadini
Copy link

arkadini commented Jun 5, 2021

I've noticed this problem, too, when I split my small Elm project into several source files: after any compilation error, changes to files included from the main Elm file are not detected (I'm at 2.0.0-beta.3.1).

I've looked into the source code of the Elm transformer: the invalidations related to the source files included from the main Elm file are added to the main Asset object (by addIncludedFile()), but if compilation fails an exception is thrown from the transform() method of the transformer plugin, and the modified Asset object (with invalidations) is lost, making Parcel "lose track" of any included dependency Elm files.

Looking more through the core part of Parcel, I can't find a clean way to pass information about a failed transformation that would preserve the invalidations. That might be a reason for similar reports in some of the other transformation plugins / file formats (#5965) and why #6072 didn't solve this problem.

neurodynamic pushed a commit to kickstartcoding/debug_trainer_app that referenced this issue Jun 11, 2021
@pfiadDi
Copy link

pfiadDi commented Jun 16, 2021

Same here with every parcel 2.0 version, with Elm on Mac M1 OS 11.2.1

@myrho
Copy link

myrho commented Jun 29, 2021

Workaround for vim: autocmd BufWritePost *.elm :silent exec "!touch src/index.html"

@domenkozar
Copy link

I don't get this bug with rc.

@wadouk
Copy link

wadouk commented Sep 2, 2021

@domenkozar are you sure ? on linux or osx when elm build failed, had to reload the build to recover.
yarn 1
parcel 2 RC 0
node 14

@domenkozar
Copy link

It works for me on linux, same verisons.

@domenkozar
Copy link

Ah sorry, it works for Main.elm but not other files.

@domenkozar
Copy link

@mischnic have you read #6124 (comment) - it might give a clue why plugin caching isn't working

@domenkozar
Copy link

There was a similar bug in v1: #2475

@n1k0
Copy link

n1k0 commented Sep 27, 2021

Just to add my voice here, tested 2.0.0-nightly.843 today and the bug still exists.

@n1k0
Copy link

n1k0 commented Sep 27, 2021

Similar to what @myrho suggested for Vim users, here's a more generic node-based workaround using chokidar-cli and concurrently:

{
  "scripts": {
    "start:watch": "chokidar 'src/**/!(Main).elm' -c 'touch src/Main.elm'",
    "start": "concurrently -n \"watch,parcel\" -c \"blue,green\" -k \"npm run start:watch\" \"parcel serve index.html\""
  }
}

@domenkozar
Copy link

I don't have time to fix this, but I'm willing to chip into whoever picks it up!

Doesn't have to be mergable, just that it works and improves my feedback loop.

It's most likely very similar to #2475 but for v2.

@voneiden
Copy link

@devongovett this issue got inadvertently closed.

@mischnic mischnic reopened this Nov 29, 2021
@objarni
Copy link

objarni commented Dec 29, 2021

I'm getting this with parcel 2.0.1 too; no reload when modifying src/Main.elm. Modifying index.html reloads in browser, as well as styles.css which is included in index.html. The src/Main.elm is indirectly included via a app.js script, which id directly included in index.html.

This happens even before any compiler error from elm.

@ChristophP
Copy link
Contributor

ChristophP commented Jan 10, 2022

I tried upgrading one of my Elm projects to parcel v2. I'm seeing the same issue: No recompilation after a breaking edit in any other elm file than Main.elm.

Everything else worked well. Would be so good to have this fixed. It's the only thing stopping Elm users from migrating to Parcel v2.

@ChristophP
Copy link
Contributor

@n1k0 Thanks this chokidar and concurrently workaround works nicely for now.

@atlewee
Copy link

atlewee commented Jan 15, 2022

I have the same issue. And the suggestion over by touching the Main.elm file did break hot-reloading for me.
I found that touching index.js whenever any elm file changes will preserve the hot reloading functionallity :)
in package.json

  ...
  "scripts": {
    "start": "concurrently \"npm run touchindex\" \"parcel serve\"",
    "touchindex": "nodemon --watch src --ext 'elm' --exec  \"touch src/index.js\""
  },
  ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet