https://serverless-stack.com/ logo
#random
Title
# random
g

Gjorgji Kjosev

03/12/2022, 9:14 PM
Hmm, I'm toying around with using SST in a monorepo and I think I'd like to try this approach:
apps
,
services
,
packages
and
infra
. Each "service" should have its package.json
"main"
point to an exported stack, which may take dependencies as props. Each app (there will be two really, web and mobile app) similarly exports a "main" which is a stack (well a mobile app doesn't, a web one does). Packages are libraries, their
main
points to the library entrypoint, and should be usable from any of the frontends or backends (shared types, configs, validations go here).
infra
basically contains the main SST index which ties the services and front ends together. Thoughts? 😅
So far its actually not looking bad at all, though some explicit path passing needs to happen (e.g.
--path
in sst-env and some other pre-resolved paths with
require.resolve
)
one bit to really make this neat is (I believe someone mentioned it somewhere)
--wait
in sst-env, which would let turborepo run
dev
in parallel in the infra and (web) app (or infra + mobile app)
to clarify on require.resolve, it looks something like this
const moduleDir = path.dirname(require.resolve("@prject/service-name/package.json"))
- and then this is used to pass
srcPath
🙂
g

gligor

03/13/2022, 7:57 AM
Any chance you can please share a sample open source repo of this set up? Looks like a good idea and set up to me.
g

Gjorgji Kjosev

03/13/2022, 11:41 AM
Yep I was thinking of making a template after everything is smooth
currently debating whether to instead go with a flat package structure and have 2 packages per app/service, app and
app-infra
the stack-in-the-app approach seems to work, but I worry local app specific tsconfig / eslint / etc could interfere if present
had to go with a separate pkg for the stack that is pre-built with tsc. this is due to esbuild building a JS file that isn't able to
require
the typescript file outside of dev mode. Still think its turning out pretty clean so far. Will update once its ready.
s

Sam Frampton

03/22/2022, 1:59 PM
@Gjorgji Kjosev I've been using lerna, ts, monorepo with sst. My starting point was this repo, i think it's good starting point and I added sst stack to it: https://github.com/mike-north/js-ts-monorepos/tree/solution I've gone for
packages
scripts
stacks
at root with lerna.
81 Views