You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The backend and web are the main frontend and backend apps, utils is a dependency in both web and backend, and ui-lib is a dependency in the web app.
Currently I have used typescript package references to setup the cross dependencies by following the below steps
Run yarn workspace @my-monorepo/backend add @my-monorepo/utils to add utils as a dependency in backend package.json
The build runs fine, and then I am also able to start the app, and it works as expected.
The only problem is when I remove the old builds and then try to run the backend development server using nodemon and ts-node, it fails to startup because it expects the build output of the utils workspace to be present.
Once I run the build command, everything goes back to normal and the development server also works fine.
Is this an expected behavior? I initially expected the development server to startup even if the build outputs of the cross referenced workspaces are not present, but now I'm confused since there are a lot of moving pieces - tsc, nodemon, ts-node, the node module resolution algorithm, and yarn pnp
What would be a recommended way of setting up such a monorepo?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I am setting up a monorepo style project with workspaces, the project structure is as follows
The
backend
andweb
are the main frontend and backend apps,utils
is a dependency in bothweb
andbackend
, andui-lib
is a dependency in theweb
app.Currently I have used typescript package references to setup the cross dependencies by following the below steps
Run
yarn workspace @my-monorepo/backend add @my-monorepo/utils
to add utils as a dependency in backend package.jsonUpdate the tsconfig of the utils workspace
Update the tsconfig of backend workspace
The build runs fine, and then I am also able to start the app, and it works as expected.
The only problem is when I remove the old builds and then try to run the backend development server using
nodemon
andts-node
, it fails to startup because it expects the build output of theutils
workspace to be present.Once I run the build command, everything goes back to normal and the development server also works fine.
Is this an expected behavior? I initially expected the development server to startup even if the build outputs of the cross referenced workspaces are not present, but now I'm confused since there are a lot of moving pieces -
tsc, nodemon, ts-node, the node module resolution algorithm, and yarn pnp
What would be a recommended way of setting up such a monorepo?
Beta Was this translation helpful? Give feedback.
All reactions