Sharing Functions Between Frontend and Backend Repos Causes Unknown Channels Issue

While this may not be a recommended case, but I have two repos (one backend and one to be serverless frontend) and wanted to share the functions in the frontend repo with the backend so I extended the rootDir in tsconfig (backend) to be ../ to be able to utilize the functions in the frontend. But I'm wanting to share a RemoteFile layer and it does successfully get called and recognized as an effect, but the channels in it are listed as unknown and I don't know why. When I move the file into the backend again it works fine.

frontend code
import { Context, Effect, Layer } from "effect";
import { remoteRetryPolicy } from "../remote-retry-policy";
import { HttpClient, HttpClientRequest } from "@effect/platform";

const remoteFetch = (remotePath: string) =>
  Effect.retry(HttpClientRequest.get(remotePath).pipe(HttpClient.fetchOk), remoteRetryPolicy);

export class RemoteFile extends Context.Tag("@frontend/RemoteFile")<
  RemoteFile,
  { readonly get: typeof remoteFetch }
>() {
  static readonly live = Layer.succeed(
    RemoteFile,
    RemoteFile.of({ get: (remotePath: string) => remoteFetch(remotePath) })
  );
}


backend code
import { Effect } from "effect";
import { RemoteFile } from "@frontend/src/assets/lol/utils/services/RemoteFile";

export const fetchRemoteJson = <A>(remotePath: string) =>
  RemoteFile.pipe(
    Effect.flatMap((remoteFile) => remoteFile.get(remotePath)),
    Effect.flatMap((res) => res.json),
    Effect.map((_) => _ as A),
    Effect.scoped
  );


the type of remoteFile above is
(parameter) remoteFile: {
    readonly get: (remotePath: string) => Effect.Effect<unknown, unknown, unknown>;
}

the type of remoteFetch in RemoteFile.ts is
const remoteFetch: (remotePath: string) => Effect.Effect<HttpClientResponse, HttpClientError, Scope>
Was this page helpful?