-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Defer throwing asset errors until after dependencies are handled. #2475
Defer throwing asset errors until after dependencies are handled. #2475
Conversation
This allows compiled langauges like Elm that handle their own dependency compilation to set up watchers for dependencies so that hot-reload continues to work due to errors in new depdenencies. Fixes parcel-bundler#2147.
I'm not entirely sure why this fix is necessary, but without it a compile error during a rebuild results in Parcel printing "Unknown error" instead of anything useful. Since we are intecepting the error though, we can also remove redundant stack information.
generateErrorMessage(err) { | ||
// For some reason, if not converted to a plain object, | ||
// the error message is lost somewhere between Pipeline.js | ||
// and Bundler.js. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fixes an issue for Elm, but I probably also need to do something like this in Pipeline.js
for other asset types that throw Error
s. I'm not certain why this is necessary, but I suspect that there's an object copy somewhere in WorkerFarm
that causes data to be lost if Pipeline.process
returns an obejct containing an Error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fixed.
This prevents error data from being lost when Pipeline is run via `WorkerFarm`.
@MattCheely tests still seem to fail (although they were fixed yesterday). |
@domenkozar Tests have been working for me locally for the most part, but I have noticed occasional timeouts on the hmr tests (mine and others), which seems to be part of the problem here. I don't have much insight into what's causing it, but there are a couple of things I can do to try simplifying the tests. |
@DeMoorJasper is that a known issue? |
@domenkozar it only appears to be a consistent issue with this PR. But it’s a known issue that the tests are no longer stable. Sent with GitHawk |
@DeMoorJasper I tidied up my hmr tests a bit and the last set of failures in the test run don't seem to be related to my changes. Let me know if there's something I should do to resolve that. FWIW, one thing I have noticed is that I see hmr tests timeout more frequently when running them in isolation via: |
@MattCheely Looks like you fixed it if I look at the CI results, not sure why the babel autoinstall is failing but that's probably another issue unrelated to this PR |
I'd love to test this in my project, but couldn't find a way or documentation how to install parcel from a local folder. |
@domenkozar to test in your project locally, run Edit: Or are you running globally installed parcel from the command line, rather than as a local project dependency? |
Thanks @MattCheely - it does fix the issue. I wonder if error messages are fixed though, I still see two of them:
|
My thinking is that due to https://github.com/rtfeldman/node-elm-compiler/blob/master/src/index.ts#L126 we can't get elm not to report the error, so we could only tell parcel to skip it. |
@MattCheely I think there was a typo, now it works correctly with:
|
Happy new year 🎉 thanks for all of the work with above patch it works great! |
@domenkozar I will see if I can get that working again. It should be possible, at least for the parcel browser overlay. I probably accidentally reverted my previous fix when I was changing the way errors are handled in |
Do tests run in parallel? There are some elm corruption errors that are known issue if you mess around with cache or run things in parallel. elm/compiler#1845 Maybe doing |
Ah actually that's probably an old annotation. https://dev.azure.com/devongovett/devongovett/_build/results?buildId=627 shows only the known transient error. @DeMoorJasper can we merge this? |
@domenkozar unfortunately only Devon can merge PRs with failing tests. |
seems to pass now :) |
Thank you! Now we wait for the Parcel 1.11.1 that will make Elm development with Parcel a breeze :) |
@DeMoorJasper do you have an idea if Parcel bugfix release will happen anytime soon? So I either look into setting up using Parcel master or just wait for bugfix release. Thanks! |
I uploaded parcel-bundler-fork to npm based on the current master to unblock my workflow. I plan to delete it as soon as 1.11.1 is out - thank you all again! |
) * Defer throwing asset errors until after dependencies are handled. This allows compiled langauges like Elm that handle their own dependency compilation to set up watchers for dependencies so that hot-reload continues to work due to errors in new depdenencies. Fixes #2147. * Fix Elm error generation. I'm not entirely sure why this fix is necessary, but without it a compile error during a rebuild results in Parcel printing "Unknown error" instead of anything useful. Since we are intecepting the error though, we can also remove redundant stack information. * Add test for tracking dependencies on error * revert hmr-runtime changes * Transform all errors in Pipeline.process. This prevents error data from being lost when Pipeline is run via `WorkerFarm`. * Separate error-depenency test input from basic Elm tests. * Update ElmAsset.js
) * Defer throwing asset errors until after dependencies are handled. This allows compiled langauges like Elm that handle their own dependency compilation to set up watchers for dependencies so that hot-reload continues to work due to errors in new depdenencies. Fixes #2147. * Fix Elm error generation. I'm not entirely sure why this fix is necessary, but without it a compile error during a rebuild results in Parcel printing "Unknown error" instead of anything useful. Since we are intecepting the error though, we can also remove redundant stack information. * Add test for tracking dependencies on error * revert hmr-runtime changes * Transform all errors in Pipeline.process. This prevents error data from being lost when Pipeline is run via `WorkerFarm`. * Separate error-depenency test input from basic Elm tests. * Update ElmAsset.js
↪️ Pull Request
Previously submitted in #2468 and #2344 (sorry about the confusion)
This allows compiled langauges like Elm that handle their own dependency
compilation to set up watchers for dependencies so that hot-reload
continues to work due to errors in new depdenencies. Fixes #2147.
There are also a few tweaks to
ElmAsset
to make sure compilation errorsare thrown after dependency collection
💻 Examples
Main.elm:
Broken.elm:
🚨 Test instructions
Using the files above, start the parcel server, and navigate to localhost:1234.
Add a line in
Main.elm
to importBroken.elm
:Notice that the build fails
Update
Broken.elm
by changing the value2
to"foo"
.In current parcel: no rebuild is triggered
In this branch: the error is resolved
✔️ PR Todo
I will try to create a test for this in the hmr integration tests, now that I am more familiar with the tests.