ducktors / turborepo-remote-cache

Open source implementation of the Turborepo custom remote cache server.
https://ducktors.github.io/turborepo-remote-cache/
MIT License
1.03k stars 95 forks source link

Consider removing @vercel/node from the dependencies #154

Closed ysgk closed 1 year ago

ysgk commented 1 year ago

🐛 Bug Report

Currently, the installation size of this package is huge. This is partly due to @vercel/node, which lists an old version of typescript as its dependency, not a peer dependency. The size of turborepo-remote-cache is 202MB, of which typescript alone is more than 50MB. If your project uses a newer version of typescript, as most likely it does, two different versions will be installed, which means typescript alone will be over 100MB in size. They are discussing about moving typescript to peer dependencies, but will not happen for the time being.

However, @vercel/node is currently only used for some trivial type information in this package: VercelRequest and VercelResponse. These two type definitions are nothing but the following:

import { ServerResponse, IncomingMessage } from 'http';
export declare type VercelRequestCookies = {
    [key: string]: string;
};
export declare type VercelRequestQuery = {
    [key: string]: string | string[];
};
export declare type VercelRequestBody = any;
export declare type VercelRequest = IncomingMessage & {
    query: VercelRequestQuery;
    cookies: VercelRequestCookies;
    body: VercelRequestBody;
};
export declare type VercelResponse = ServerResponse & {
    send: (body: any) => VercelResponse;
    json: (jsonBody: any) => VercelResponse;
    status: (statusCode: number) => VercelResponse;
    redirect: (statusOrUrl: string | number, url?: string) => VercelResponse;
};

It doesn't seem to me this is worth the 50MB disk size. Therefore, I suggest that you consider removing @vercel/dev, at least for the time being.

To Reproduce

npm init -y
npm install turborepo-remote-cache typescript@4.9.5 --save-dev
du -sh node_modules # 265M
du -sh node_modules/typescript # 64M
du -sh node_modules/@vercel/node/node_modules/typescript # 58M

Expected behavior

Only one version of typescript will be installed, reducing the installation size.

Your Environment

matteovivona commented 1 year ago

@fox1t, it might make sense to remove Vercel dep

fox1t commented 1 year ago

@ysgk are you using this package as a library? If so we should extract the needed parts and make it importable/requirable. I like the idea since it will transform this package into a monorepo. We can use https://github.com/ducktors/crane and inject the monorepo.

ysgk commented 1 year ago

@fox1t I use it mainly as a command line tool in CI. So actually, the type information is completely unnecessary for me. But it seems like a good idea to make it a monorepo to isolate the type information.

fox1t commented 1 year ago

OK. We will work soon on this. Thanks for reporting!

matteovivona commented 1 year ago

@fox1t I'd remove the support for Vercel. It's pretty useless right now https://github.com/ducktors/turborepo-remote-cache/issues/159

fox1t commented 1 year ago

Might be a good solution. It will be a major bump and we need to provide an alternative. I need to think about it a little bit more.

trm217 commented 1 year ago

I would really appreciate it, if Vercel could remain as a option to deploy the custom cache to. :)

fox1t commented 1 year ago

I agree. I don't like to cut features we already have.