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: typechecking newly added imported file doesn't trigger reload #2147

Closed
domenkozar opened this Issue Oct 15, 2018 · 5 comments

Comments

Projects
None yet
3 participants
@domenkozar
Copy link

domenkozar commented Oct 15, 2018

馃悰 bug report

In file B, importing a new file A that doesn't initially typecheck doesn't trigger reloads on subsequent changes.

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

Barebones elm project.

馃 Expected Behavior

When file A is saved, parcel reloads.

馃槸 Current Behavior

Nothing happens when saving file A, one needs to save file B.

馃拋 Possible Solution

馃實 Your Environment

Software Version(s)
Parcel 1.10.3
Operating System Linux

@domenkozar domenkozar changed the title Elm: importing Elm: typechecking newly added imported file doesn't trigger reload Oct 15, 2018

@domenkozar

This comment has been minimized.

Copy link

domenkozar commented Oct 16, 2018

@domenkozar

This comment has been minimized.

Copy link

domenkozar commented Oct 20, 2018

Could be an upstream bug in https://github.com/NoRedInk/find-elm-dependencies#usage, need to test that next time it happens.

@domenkozar

This comment has been minimized.

Copy link

domenkozar commented Oct 30, 2018

Got this again today. findAllDependencies('./src/Main.elm').then(function(deps) { console.log(deps); }); did return the offending file. Restarting parcel fixes the issue.

@DeMoorJasper any tips how to debug how parcel picks up file changes?

@domenkozar

This comment has been minimized.

Copy link

domenkozar commented Oct 31, 2018

The problem might be that there is an error:

    at ChildProcess.<anonymous> (/home/ielectric/dev/cachix/cachix-server/frontend/node_modules/node-elm-compiler/index.js:149:27)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:925:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
@MattCheely

This comment has been minimized.

Copy link
Contributor

MattCheely commented Nov 16, 2018

I did some research on this and it seems the issue is that when the compile process throws an error, all processing of the asset halts, and any collected information such as dependencies is thrown away. At a high level, this happens in Bundler.js on line 556, and dependencies aren't watched until line 578.

There are a few ways to potentially fix this, but I think the ideal situation would be to let Asset.generate return something that indicates that the asset is in error, while still retaining other data. Maybe something as simple as {error: '...'}. One nice thing about that would be that it would make errors more of a first-class part of the pipeline and open the door for things like customizing the error display in nice ways. That could be pretty interesting with tools like Elm and Rust that produce really nice error information.

I'd be happy to try tackling this problem, but I want to make sure I'm doing work that makes sense in the context of the larger project. @DeMoorJasper or @devongovett - What's the best way to approach this? I can just start slinging code and open a PR, but if there's a particular approach you think would be best, I'm happy to go that route.

MattCheely pushed a commit to MattCheely/parcel that referenced this issue Dec 2, 2018

Matthew Cheely
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 parcel-bundler#2147.

domenkozar added a commit to domenkozar/parcel that referenced this issue Dec 26, 2018

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 parcel-bundler#2147.

MattCheely pushed a commit to MattCheely/parcel that referenced this issue Dec 26, 2018

Matthew Cheely
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 parcel-bundler#2147.

MattCheely pushed a commit to MattCheely/parcel that referenced this issue Dec 27, 2018

Matthew Cheely
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 parcel-bundler#2147.

MattCheely pushed a commit to MattCheely/parcel that referenced this issue Dec 28, 2018

Matthew Cheely
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 parcel-bundler#2147.

DeMoorJasper added a commit that referenced this issue Jan 3, 2019

Defer throwing asset errors until after dependencies are handled. (#2475
)

* 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

maumercado added a commit to maumercado/parcel that referenced this issue Jan 4, 2019

Defer throwing asset errors until after dependencies are handled. (pa鈥
鈥cel-bundler#2475)

* 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 parcel-bundler#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

maumercado added a commit to maumercado/parcel that referenced this issue Jan 4, 2019

Defer throwing asset errors until after dependencies are handled. (pa鈥
鈥cel-bundler#2475)

* 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 parcel-bundler#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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment