simondotm / nx-firebase

Firebase plugin for Nx Monorepos
https://www.npmjs.com/package/@simondotm/nx-firebase
MIT License
175 stars 31 forks source link

serve or build in `--watch` mode does not watch dependent libraries also #20

Closed simondotm closed 1 year ago

simondotm commented 3 years ago

Scenario: Functions project depends on node-library Run build --with-deps --watch Changes to dependencies and/or main application code result in inconsistent rebuilds

Look into nx-watch plugin to resolve this https://gist.github.com/jhesgodi/2d530753c551ace665a8c3010d3a719c

simondotm commented 3 years ago

Theres a rumour this used to work on Nx v11.x , but I cant find the github issue I spotted with this info in it

simondotm commented 3 years ago

It's Nx issue 5762

KingDarBoja commented 3 years ago

It's Nx issue 5762

Copying the issue so the related fix can be tracked: https://github.com/nrwl/nx/issues/5762

simondotm commented 3 years ago

Recent Nx changes offer some new possibilities here, observer on the tsc process could be just the ticket Dropping here for reference https://github.com/AgentEnder/nx/commit/c95f24660c14b82034d5393e97195cfc99fea009

IdanCo commented 2 years ago

Great project!!!

I've solved this issue outside nx by building the library INTO the functions folder. Not sure this strategy would work in this case. I see you're copying the built library only once. Any chance to update it on every change as well?

I wrote my recipe for the non-nx solution, hope it could be of use. Let me know If I can get involved somehow. Auto-refreshing the firebase functions is a dream of mine.

simondotm commented 2 years ago

Thanks for sharing your approach, and yes, I'd love to get this working somehow.

Building libraries directly into the functions folder is a neat idea but doesn't feel quite right as a solution for Nx workspaces since we cant always be sure a given buildable library won't be a dependency of multiple apps in the workspace.

Generally seems like we'll need to somehow figure out how an nx plugin can watch specific folders or dependencies (we do know all of the target libraries that a functions application depends on, so thats a good start) and then run its own logic (copying the updated lib outputs in our case) whenever there's a change detected.

Reading the comments in various Nx threads though atm, I get the feeling this functionality exists but is a little bit fragile - keeps working, then not working across recent releases. I'm tempted to see how Nx team resolve some of these features, and then we can follow their examples.

I'm always open to ideas though!

simondotm commented 1 year ago

See #95