rxdi / firelink

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

Add support for nested linked packages #29

Closed mvgijssel closed 2 years ago

mvgijssel commented 2 years ago

This library works perfectly well if you have a single level of monorepo dependencies. The firebase functions package.json file:

{
  "dependencies": {
    "@graphql/database": "link:../../packages/database",
    "@graphql/shared": "link:../../packages/shared",
    "@graphql/introspection": "link:../../packages/introspection",
  },
  "fireDependencies": {
    "@graphql/database": "../../packages/database",
    "@graphql/shared": "../../packages/shared",
    "@graphql/introspection": "../../packages/introspection"
  }
}

the link statements are replaced with their file counterparts pointing to the inlined packages.

But it doesn't work if for example the @graphql/database package also has a similar dependency on @graphql/shared like:

{
  "dependencies": {
    "@graphql/shared": "link:../../packages/shared",
  },
  "fireDependencies": {
    "@graphql/shared": "../../packages/shared"
  }
}

in this case the link: will not replaced with file breaking the Firebase functions deploy.

Stradivario commented 2 years ago

Hi @mvgijssel i don't think this is a correct way of using the actual library you can check in the examples https://github.com/rxdi/firelink/tree/master/example

Correct package.json

{
  "dependencies": {
    "@graphql/database": "^1.0.0",
    "@graphql/shared": "^1.0.0",
    "@graphql/introspection": "^1.0.0",
  },
  "fireDependencies": {
    "@graphql/database": "../../packages/database",
    "@graphql/shared": "../../packages/shared",
    "@graphql/introspection": "../../packages/introspection"
  }
}

So here we are talking about nested dependencies since i don't quite follow ?

For example:

Root package.json looks like in the example above and you have a dependency called @graphql/database which uses package @graphql/shared is this what you are facing ?

If it is that i need to think about these topics:

  1. Is it really the purpose of the library to do this
  2. If inside @graphql/database present dependencies package called @graphql/shared with version specified it should reference directly to the node_modules and you should not get an error.
  3. Why don't you try to remove link: reference since i think this is what causing the issue at first place

You can contact me at my email kristiqn.tachev@gmail.com and we can arrange some Calendar Meeting in order to debug this more further to understand what is the core of the problem.

Cheers!

mvgijssel commented 2 years ago

Root package.json looks like in the example above and you have a dependency called @graphql/database which uses package @graphql/shared is this what you are facing ?

Yes this is the issue I'm facing! Recursive dependencies with the link: statement.

Why don't you try to remove link: reference since i think this is what causing the issue at first place

I'm using link instead of file, because that makes developing the libraries easier and doesn't require a re-install after every change!

Now I'm trying to force the firebase functions install to use yarn instead of npm, so the link keyword won't be a problem. I'll let you know if this works!

mvgijssel commented 2 years ago

I've settled now for not having dependencies that have dependencies with the link: yarn feature to be able to deploy to firestore functions. I'll revisit this once this becomes a problem (again). Thanks!

Stradivario commented 2 years ago

I've settled now for not having dependencies that have dependencies with the link: yarn feature to be able to deploy to firestore functions. I'll revisit this once this becomes a problem (again). Thanks!

Cool man please reopen the ticket if you face the problem again i will write a note for this scenario :)