simondotm / nx-firebase

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

Build with --watch flag #11

Closed enejm closed 3 years ago

enejm commented 3 years ago

Hello. Great plugin. Is there a way to run the builder in watch mode for hot reloading purpose?

I have tried nx build myapp --watch=true

It starts compilation in watch mode but it exits after first execution.

simondotm commented 3 years ago

Interesting question. Can I ask how you would be using --watch with functions? Is it for just checking for compile errors as you work, or for some other interesting reason?

simondotm commented 3 years ago

Looks like this was a bug in Nx thats fixed in 12.3.4 - Nx issue 5208 Plugin may need to rearrange the order it does its work however to:

  1. Build dependent libraries
  2. Copy libraries to dist
  3. Update package.json
  4. TSC compile the functions library (has to be the last step in case of watch mode)

--watch should work in this case. However changes to dependent libraries wont be detected for rebuilding the functions app output.

simondotm commented 3 years ago

I dont think it's going to be trivial to support --watch because we do post processing on the build. I cant do the tsc step last, because it deletes the output folder before compilation (which nukes the package.json and local library deps we've created).

Hmmm....

enejm commented 3 years ago

Regarding the use case:

In regular firebase functions repo I mostly use npm run build -- --watch | firebase emulators:start This way I can test functions in functions shell or in frontend app without need to manually rebuild it on every change.

So in regards to issue #9 - I intended to set up nx serve with build command using --watch flag

Ideal dev experience for fullstack development would be: To serve both functions and frontend app, and any change in apps and especially in common libs would be applied without need to manually rebuild and rerun emulators again.

enejm commented 3 years ago

Hmm, yes, I understand. If it is not trivial issue, than I will stick to "manual". :) Thank you for your time.

simondotm commented 3 years ago

Thanks for the extra info. I've got an idea there might be a way to do this, and its a useful thing for the plugin to do, so I'll look into it.

simondotm commented 3 years ago

Ok I've figured this out. --watch will be supported in the next release.

simondotm commented 3 years ago

v0.2.3 now released against Nx version 12.3.4

--watch is now supported in v0.2.3 - requires minimum Nx version 12.3.4

simondotm commented 3 years ago

@enejm - Please note project has now been renamed to @simondotm/nx-firebase, see here for the new 0.3.0 release.