Closed puchm closed 3 years ago
Hi - the issue seems to be that the babel plugin embeds the definition of test.graphql
into main.js
. Dependencies from one file to another are not tracked and are not usually present in Babel. You can see that the definition changes correctly once you re-save main.ts
.
You can run with DEBUG="babel-watch:*" npm start
to see the full inner workings of babel-watch
.
There is no way to avoid this in the current code. It is tempting to add a --no-cache
option or similar, but doing so would essentially make this the same as running nodemon
with @babel/register
, as the cache is what makes babel-watch
worthwhile.
I'm going to close this as a use case we can't support, unfortunately.
So essentially babel is caching it, not babel-watch? And because babel doesn't know that main.ts depends on the GraphQL file, it doesn't rebuild main.ts? Am I understanding this correctly?
babel-plugin-import-graphql has a runtime
option, but it doesn't do anything as far as I tested it. I am going to open an issue there.
On a side note: Could you please look at the pull request I opened a few weeks ago? It's a totally different topic but I think it's useful and would be curious what you think about it.
babel-watch
is caching it, by file. But while it invalidates the test.graphql
cache, the reality is that main.js
contains test.graphql
, so removing the cache does nothing.
I have noticed that some files do not get updated on restart.
Steps to reproduce
I built a simple repo that shows the problem: https://github.com/puchm/babel-watch-error-demo
npm start
test.graphql
fileThe app will restart, but the changes will not be taken over as you can see in the log. Once you restart babel-watch, the changes are visible.
I have investigated a bit and it seems like the GraphQL file is not getting saved in the
cache
object so that is not the explanation. I looked around the code for quite some time but I don't have any idea what could be causing this.Thanks for your help. -Moritz