Separating Client and Lambda NPM Packages, monorepo

Im very new to Netlify, Just worked through a few tutorials, and got a react app with apollo graphql lambda function deployed and working. Which is awesome, but I something is bugging me.
All the examples bundle the npm package dependencies for the react app, and serverless functions in the one package.json. Am I right in assuming there is no bunding overhead as only the packages explicitly required are bundled? But thats not the problem.

The problem is I want best of both worlds - Continuous Deployment, but also monorepo like organisation, and a way of not having one massive package.json. Sorting out dependencies is hard enough!

Hopefully this is a newb question, someone further down the path can enlighten me please!

Thx

H

Currently there’s no practical way to have multiple workspaces in a single repo.

See: Best practices for deploying sites from monorepos? - #2 by fool

This would be a nice to have.

Thanks Stefan. Yes, not a straightforward issue. Having split package.json's and a combinative pre process feels hacky. I might just use comments to keep track for now i.e.:

"dependencies": {
    "//": "CLIENT DEPS",
    "apollo-boost": "^0.4.0",
    "react": "^16.8.6",
    "react-apollo": "^2.5.6",
    "react-apollo-hooks": "^0.4.5",
    "react-dom": "^16.8.6",
    "react-scripts": "3.0.1",
    "//": "SERVER DEPS",
    "netlify-lambda": "^1.4.13",
    "apollo-server-lambda": "^2.6.1",
    "http-proxy-middleware": "^0.19.1",
    "nexus": "0.11.7",
    "nexus-prisma": "0.3.7",
    "prisma-client-lib": "1.34.0",
    "//": "SHARED CLIENT-SERVER DEPENDECIES",
    "graphql": "^14.3.1",
    "//": "PEER DEPENDECIES",
    "bufferutil": "^4.0.1",
    "encoding": "^0.1.12",
    "typescript": "^3.5.1",
    "utf-8-validate": "^5.0.2",
    "apollo-client": "^2.6.0-rc.3"
  },
1 Like

Hey @henrykempo, in case you’re interested, I found a way to work reliably with workspaces: Using pnpm and pnpm workspaces

1 Like