rxdi / firelink

Firebase. gcloud and monorepos are not combining very well until they met @rxdi/firelink
MIT License
68 stars 9 forks source link

Copied package not building #1

Closed AylanBoscarino closed 2 years ago

AylanBoscarino commented 4 years ago

I work in a monorepo that have a common package called core that is shared among the other projects of the monorepo.

The core package mostly contains only interfaces, but latter I added some common utility functions that should be used in the projects of the repo.

After writing one function I could no longer deploy the Firebase functions project to GCP because the server environment was not finding the core package anymore.

I noted that the copy made to the .package folder was missing the dist folder that was being pointed in the core's package.json as the place containing it's index.js. When I copied the dist folder to the .package's core folder I could deploy my project again.

After that I moved to firelink's source code and saw that it was the intended behaviour to explicitly remove the dist folder when copying a imported package, but it's clear that GCF don't compile the projects in the .package folder. (and probably don't install any dependencies either)

My question is, what is the recommended way for deploying the functions in this situation? Is there a way to make GCF compile the .package folder within my functions project at deployment time? Should I move the compiled code out of the core's dist folder and put in one with another name? (sounds like a hack)

Anyway I'm not sure what's the best practice when solving this kind of problem and would be grateful for some insights.

Thanks in advance.

Stradivario commented 4 years ago

I am looking for resolution of your question!

In the meantime if you want you can contact me at hangouts "kristiqn.tachev@gmail.com". If you have time you can share screen and discuss what we should do in this particular scenario!

@AylanBoscarino

cupcakearmy commented 3 years ago

Is there a reason the dist folder gets ignored?

Stradivario commented 3 years ago

Is there a reason the dist folder gets ignored?

Hi! Kind of strange why i decided to ignore dist folder here https://github.com/rxdi/firelink/blob/1cc46b690cc175bdef715fdc76b4523b4bc505e1/src/helpers/copy-packages.ts#L12

I am thinking why i did this since every node_module installed has dist folder with bundled files in it. Quite strange why this was working and what was the purpose of ignoring it.

Need to check

cupcakearmy commented 3 years ago

For me it ended up making my app not working as my typescript output is the dist folder. I simply wrote a small script that just yarn packs the content of the packages and copies the zip to the functions folder with the file:./foo.tgz just like you do with rsync. If there is no actual reason to exclude dist it probbly should not.

Thanks for the inspiration for solving the issue though! I was going crazy 😅

Stradivario commented 2 years ago

@cupcakearmy Sorry for the late reply!

This issue should fix this problem also

https://github.com/rxdi/firelink/issues/11

Cheers!

Stradivario commented 2 years ago

Please re-open this issue if the problem appears again which i doubt it will since there is no logic for ignoring any files or folders.

Later on i will introduce a way to ignore files using .fireignore where you can specify which files needs to be ignored when the packages are copied.

With latest npm version 7 there is a nice feature where .packages folder is automatically symlinked to node_modules so when you edit packages it will reflect directly to node_modules.

aalises commented 2 years ago

looking for a solution to this @Stradivario , which could be related.

Is there a way to make GCF compile the .package folder within my functions project at deployment time?

All my packages are written in Typescript. Basically, I would want the .packages folder to be transpiled by typescript before deploying, any idea?