Pnpm Workspace
Directory Structure
.
├── apps
│ └── fizzbuzz
│ ├── package.json
│ └── src
│ └── index.ts
├── biome.json
├── package.json
├── packages
│ └── fizzbuzz
│ ├── package.json
│ └── src
│ └── index.ts
└── pnpm-workspace.yaml
pnpm-workspace.yaml
yaml
packages:
- 'apps/*'
- 'packages/*'
package.json
json
{
"name": "pnpm-workspace-tsx-test",
"scripts": {
"fmt": "pnpm biome format --write ./"
},
"devDependencies": {
"@biomejs/biome": "^1.9.4",
"tsx": "^4.19.1"
}
}
apps
package.json
json
{
"name": "@apps/fizzbuzz",
"private": true,
"dependencies": {
"@packages/fizzbuzz": "workspace:*"
}
}
TypeScript
ts
import { fizzBuzz } from '@packages/fizzbuzz'
console.log('Hello World!')
console.log(fizzBuzz(100))
packages
package.json
json
{
"name": "@packages/fizzbuzz",
"private": true,
"main": "src/index.ts"
}
TypeScript
ts
export const fizzBuzz = (number: number): string => {
if (number % 15 === 0) return 'FizzBuzz'
if (number % 3 === 0) return 'Fizz'
if (number % 5 === 0) return 'Buzz'
return number.toString()
}
Execution
sh
pnpm install
pnpm tsx watch apps/fizzbuzz/src/index.ts
Hello World!
Buzz