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
Hey there ✋
In the Autospace Workshop project, at one stage of development we were obliged to change managers to solve the problem of hoisting dependencies, Yarn compared to PNPM seemed to do the trick, I've found a solution and I'd like to share it:
Configuration for a pnpm monorepo with GraphQL and NestJS
Configuration steps
1. configure dependency hoisting
Add a .npmrc file to the project root with the following contents:
shamefully-hoist=true
This configuration allows pnpm to "hoist" dependencies, making them easier to share between monorepo packages.
2. Adjust TypeScript configuration
In the tsconfig.json of each of your packages where you make calls to externals involving the creation of a node_modules folder, such as our network library, add the following configuration:
This configuration helps TypeScript to locate modules correctly in the monorepo structure.
Advantages of this approach
Efficiency: Works with pnpm, offering better performance and optimized use of disk space. Simplicity: Avoids the need to manually specify which packages not to hoister. Compatibility: Integrates well with various frameworks and libraries, including NestJS and GraphQL.
This configuration enables dependencies to be managed efficiently in a single-repo environment, without the need for specific solutions such as Yarn's "nohoist", while maintaining compatibility with frameworks such as NestJS.
The text was updated successfully, but these errors were encountered:
Hey there ✋
In the Autospace Workshop project, at one stage of development we were obliged to change managers to solve the problem of hoisting dependencies, Yarn compared to PNPM seemed to do the trick, I've found a solution and I'd like to share it:
Configuration for a pnpm monorepo with GraphQL and NestJS
Configuration steps
1. configure dependency hoisting
Add a
.npmrc
file to the project root with the following contents:shamefully-hoist=true
This configuration allows pnpm to "hoist" dependencies, making them easier to share between monorepo packages.
2. Adjust TypeScript configuration
In the
tsconfig.json
of each of your packages where you make calls to externals involving the creation of a node_modules folder, such as our network library, add the following configuration:So the final json file in my case looks like this:
This configuration helps TypeScript to locate modules correctly in the monorepo structure.
Advantages of this approach
Efficiency: Works with pnpm, offering better performance and optimized use of disk space.
Simplicity: Avoids the need to manually specify which packages not to hoister.
Compatibility: Integrates well with various frameworks and libraries, including NestJS and GraphQL.
This configuration enables dependencies to be managed efficiently in a single-repo environment, without the need for specific solutions such as Yarn's "nohoist", while maintaining compatibility with frameworks such as NestJS.
The text was updated successfully, but these errors were encountered: