We use a full TypeScript mono repo with this structure:
project
| - packages
| - common
| - appsCommon
| - Next.js-App
| - React-Native-App
| - Google-Cloud-Functions
So far common and appsCommon are compiled from TypeScript to ES6 into a lib folder.
The tsconfig.json of the common packages look like this:
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"module": "commonjs",
"outDir": "lib",
"strict": true,
"target": "es6",
"jsx": "react"
},
"compileOnSave": true,
"include": ["src"]
}
The packages.json of the common packages look like this:
{
"name": "@project/common",
"version": "0.0.10",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"files": [
"lib/**/*"
],
...
}
This is needed for Common, that is published to npm for use by cloud functions, but this is not needed for appsCommon, that is directly used by the Next.js and React Native apps.
Hot reloading shall also work for common within the project.
Currently the global packages.json looks like this:
{
"name": "project",
"private": true,
"workspaces": {
"packages": [
"packages/*"
],
"nohoist": [
"**react**",
"**react-native**",
...
]
},
...
}
Currently the lerna.json looks like this:
{
"packages": [
"packages/*"
],
"npmClient": "yarn",
"version": "0.0.10",
"useWorkspaces": true,
I guess it is not just a matter to change lib to src in the common package.json, when I do this modules are underlined by the VS Code: "not found". Also, I know that cloud functions can use raw typescript but I don't know if it is possible to call uncompiled typescript packages.