0x80 / mono-ts

A quest for the perfect TS monorepo setup
MIT License
76 stars 7 forks source link

Lockfile and scripts after isolate #9

Closed torbjorn-kvist closed 3 months ago

torbjorn-kvist commented 4 months ago

Love the monorepo setup, been testing it out during the week and have some questions. Not sure if this is the best place for it. If not, please suggest where I should ask :)

  1. Been testing out the mono-ts example and noticed that the pnpm-lock.yaml for services/fns contains next dependencies, even when the package.json contains no such dependencies. Tried pnpm dedupe inside the isolate file and it shrinks by quite a bit.

  2. Is there anyway to run scripts after the isolate phase when using firebase-tools-isolate? Have use-case to copy some assets that I don't want isolate to "mess" with. It works with fns example, by specifying it after the isolate step in firebase.json but I saw that you wrote that example is not a recommend way of doing it.

0x80 commented 4 months ago

Not sure about the dependencies. Thanks for bringing it under my attention. I will look into it, but I'm quite swamped with stuff at the moment.

Using isolate directly is only not recommended because it's cumbersome to run the emulators like that. You don't get hot module reloading like you normally have with running the firebase emulators directly. If you don't care, then there's no harm in triggering isolate yourself before deployment.

What are you worried about concerning your assets? If you were to include the assets in the "files" field of your package.json, they will basically just get zipped and unzipped AFAIK.

torbjorn-kvist commented 4 months ago

No problem! Take your time, it's just something that I noticed when testing around. Saw that the uploaded bundle was bigger then I expected and its not a blocker. Only seems to affect the bundle upload with a couple of 100-300kb.

Can use this as a workaround in the meantime

    "predeploy": [
      "turbo build",
      "isolate",
      "cd isolate && pnpm dedupe"
    ],

The use-case I had was copy some files from another workspace package. The "files" field and running the scripts before isolate. I packaged a standalone nextjs server and use that in the deployed function. But got it working and it seems to be running without a hitch :)

Thanks for the quick response!

0x80 commented 3 months ago

@torbjorn-kvist This should be fixed in 1.12.0 and the latest version of firebase-tools-with-isolate.

I found an internal PNPM pruneLockfile function that does the job. I already had it linked, but at some point concluded that it wasn't what I needed. In this case it does exactly what we need I think.

Dedupe seems a little bit different in that it can also change versions, so the former seems the correct one to use. You are still free to run dedupe on your project before isolating of course.

Thanks again for noticing this 👍

torbjorn-kvist commented 3 months ago

Thanks for the quick fix! The lock file is way smaller now. The diff between running dedupe after is just a couple of bytes in my case, so I can skip that step now.

Thanks again for finding the problem and fixing it :)