rxdi / firelink

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

Emulators #44

Closed R-Iqbal closed 2 years ago

R-Iqbal commented 2 years ago

Hi,

I am trying to setup Firelink with our existing Firebase project with support for Firebase emulators. We are using yarn 3 workspaces.

package.json

  "fireDependencies": {
    "@claimsgate/core": "../core"
  },
  "dependencies": {
    "@claimsgate/core": "workspace:*"
  }

firelink emulators:start --only "functions"

Example function

export const testFunction = functions.region(region).https.onRequest(async (req: any, res: any) => { hello(); });


### Emulator error
```json
!  Error: Cannot find module '@claimsgate/core'
Require stack:
- C:\Users\Rayyan\Desktop\Work\Media Advancements\Projects\claimsgate\packages\claimsgate-functions\dist\endpoints\misc\testEndpoint.js
- C:\Users\Rayyan\Desktop\Work\Media Advancements\Projects\claimsgate\packages\claimsgate-functions\dist\endpoints\misc\index.js
- C:\Users\Rayyan\Desktop\Work\Media Advancements\Projects\claimsgate\packages\claimsgate-functions\dist\endpoints\index.js
- C:\Users\Rayyan\Desktop\Work\Media Advancements\Projects\claimsgate\packages\claimsgate-functions\dist\index.js
- C:\Users\Rayyan\AppData\Roaming\npm\node_modules\firebase-tools\lib\emulator\functionsEmulatorRuntime.js

If this is the correct behaviour with Firelink then potentially the issue lies with my tsconfig in my functions folder.

Any ideas / advice would be great.

R-Iqbal commented 2 years ago

Solved it, I needed a top level index.ts in my claimsgate/core

Stradivario commented 2 years ago

Glad you make it !

If you do need some assistance please let me know.

Barrel export is really common practice to expose library specific logic to outside world.

Cheers!

@R-Iqbal