#Nest.js monorepo shared package

10 messages · Page 1 of 1 (latest)

broken dust
#

I have a monorepo(not Nest.js monorepo) with multiple apps and packages. I use pnpm and turbo.
I have trouble with using shared package from Nest.js app

monorepo structure

apps
|-- api
packages
|-- shared

Now I'd like to use types from packages/shared and I got into trouble with transpilation.
I am getting error like unexpected token 'export'
And I would like to avoid the internal package to have it's own build/compliation process and want Nest.js to process it. Is this possible?

restive shell
#

I'd like to know this too, because AFAIK, there isn't a way. While using pnpm workspaces, the process is as follows.

  1. Open a console in the library and start a watch on the files for changes to recompile.
  2. Open a second console (or use something like tmux) and run the dev server on the app.
  3. Make a change in the library.
  4. (the ugly part) Restart the dev server on the app to pull in the changes from the library build.
  5. Wash, rinse, repeat.

This was so annoying to me, I also created my own dev-across-projects CLI command. However, it was designed to use Rush's build caching/ project graph, so only those projects with changes would rebuild and trigger an automatic restart of the dev server/ app watcher.

#

In other words, I can just do this:

my-cli dev project1 project2 project3

...and all projects are watched and the project that is an application fires off the dev server to run the app. So, I can develop on any number of dependencies and the app, all at the same time, in one console.

broken dust
#

I am a bit surprised that there is no way for this ☹️ because this is quite common usage when there is Nest.js in monorepo

#

Sorry for direct ping @light warren - does Nest.js have any approach for this?

crystal timber
#

I'd like to know this too. I am looking to build a fullstack monorepo with backend and frontend using turbo . Many packages are shared from the packages folder to the apps folder. But i can't use it with nestjs api

apps |-- api |-- web |-- web-admin packages |-- shared |-- ui

Turbo

Turbo is an incremental bundler and build system optimized for JavaScript and TypeScript, written in Rust.

restive shell
#

@crystal timber @broken dust - This has nothing to do with Nest at all. It's how monorepo managers work with workspaces (or don't). You'd have the same issue with any frameworks that you build apps with, which also have dependency projects in the monorepo.

crystal timber
#

@broken dust I think so, too . You can switch to Nx. It seems that Nx supports configuring monorepo more easily. rerep_one

broken dust
#

Yeah indeed. I was just thinking that it'd be great if Nest.js has example setup for pnpm turbo monorepo for this case because it's a bit common.

next gulch
#

so many monorepo discussions!