Turborepo -- how to nest applications in the 'apps' folder or different top-level directory?
Asked Answered
D

1

6

I'm trying to create a turborepo that contains several types of infrastructure like terraform, potentially 100+ 'serverless' functions.

Ideally, I'd like to organize them a bit more into a subfolder structure that makes sense, rather than have a giant 'apps' folder with hundreds of folders.

I've tried to configure the pnpm workspaces to look at nested folders and that seems fine, although turborepo doesn't seem to have any documentation or option to run/recognize nested folders.

I have attemptd to create a subdirectory structure with some basic functions that simply log on the console to confirm that turborepo picks them up by default as such:

apps
-- functions
---- function 1
---- function 2
---- more functions
------ more function 1
------ more function 2

Each with their own package.json, names and 'dev' scripts.

Unfortunately upon running dev, it doesn't see them:

enter image description here

Any advice on how to achieve this or alternative ways of looking at this problem are appreciated, thanks!

Depopulate answered 17/6, 2022 at 22:12 Comment(0)
B
3

You can use workspaces to organize your folders and have turborepo recognize them. Nested more functions won't work but you can organize folders differently so that they are direct child of a workspace.

{
  "name": "monorepo",
  "version": "1.0.0",
  "workspaces": [
    "docs",
    "apps/functions-group-a/*",
    "apps/functions-group-b/*",
    "apps/functions-group-z/*",
    "packages/*"
  ]
}
Bullion answered 23/7, 2022 at 11:55 Comment(2)
I believe "apps/**" works in a similar way too.Mortal
For performance reasons, it’s better to avoid nested glob matching like apps/**, as it will match not only the direct children, but all the directories inside the apps directory.Homoeo

© 2022 - 2024 — McMap. All rights reserved.