Closed leemhenson closed 9 months ago
@leemhenson Live reloading of changes while running the emulators is only possible if isolate is integrated in the firebase-tools, so that the emulators run on the original source code as normal.
For this reason I have forked the firebase tools. It is described in the readme, and also in this article
This is the fork https://github.com/0x80/firebase-tools-with-isolate
You can see a working example in the mono-ts boilerplate at services/api
I see that it's not super clear from this package's readme. I will add a warning to the "usage" section.
@leemhenson Live reloading of changes while running the emulators is only possible if isolate is integrated in the firebase-tools, so that the emulators run on the original source code as normal.
For this reason I have forked the firebase tools. It is described in the readme, and also in this article
This is the fork https://github.com/0x80/firebase-tools-with-isolate
You can see a working example in the mono-ts boilerplate at services/api
Maybe one day the Firebase gods will bless us with first-class monorepo support, but until then: thanks for your work.
Hey. So perhaps this is a misconfiguration on my part, but firebase code reloading is not working for me when
isolate-package
is involved.Excerpt from
firebase.json
:So,
npm run build
causestsc
to emit into./dist
and thennpm run isolate
bundles that all up into./isolate
. So far so good, the emulators boot up fine and my functions handle requests as expected.If I now make some changes and run
npm run build
, obviously nothing will change in the emulators as they are not watching that directory. Then, if I then runnpm run isolate
again, I would expect the emulators to see the changes and cycle in the new code - but it does not. At this point I have to manually kill and restart the emulators to see the new code changes take effect.I believe the cause of this behaviour is
firebase-tools
usingchokidar
to watch the./isolate/dist
directory. Every time theisolate
command is run, it removes the./isolate
directory entirely before replacing it with the new isolated bundle. The removal of the./isolate/dist
directory seems to causechokidar
to stop tracking changes, even though a new./isolate/dist
directory is created shortly after.There are a couple of unanswered issues in the
chokidar
issue tracker that talk about this behaviour, so I don't expect it be resolved there or infirebase-tools
any time soon. And since this seems to be an issue because of the way theisolate
command works, I suspect it would be easiest to fix here - probably by not deletingisolate
orisolate/dist
. Thedist
part is specific to my project too I suspect (derived frommain
inpackage.json
?), so that would need generalising too.I suppose one other workaround would be to remove isolate from
firebase.json
entirely, and only use it when deploying but that feels like more of a hack and would mean I was testing with code that wasn't necessarily identical to that which would be in the isolated bundle.