28
loading...
This website collects cookies to deliver better user experience
projectA/
projectB/
projectC/
packages/
{
"compilerOptions": {
"noImplicitAny": true,
},
"exclude": [
"**/node_modules",
"**/.*/",
"**/jest.config.js",
"**/.build"
],
}
{
...
"private": true,
"workspaces": {
"packages": [
"packages/*",
"projectA",
"projectB",
"projectC",
]
},
}
{
"name": "@company/projectA",
...
"scripts": {
"watch": "tsc -b -w --preserveWatchOutput",
...
},
"dependancies": {
"@company/types",
"@company/logging",
"@company/clients"
}
}
Now run yarn install at the root, and then at each package.
Now is a very important part. You need to add a tsconfig.json file for each of the projects. This is to assist typescript with the dependency tree. Below is an example of projectA as it depends on 3 packages — clients, types, and logging. This tells typescript to recompile if it senses any changes in the parent package.
{
"extends": "../tsconfig",
"compilerOptions": {
"outDir": ".build"
},
"rootDir": ".",
"references": [
{
"path": "../packages/clients"
},
{
"path": "../packages/types"
},
{
"path": "../packages/logging"
},
],
}