I'm currently in the process of setting up a monorepo that involves 3 services sharing some library code.
Here's how it stands at the moment:
repo: web
pdf/
package.json
referencing shared-ts via github url
tsconfig.json
frontend/
package.json
referencing shared-ts via github url
tsconfig.json
repo: mobile (react-native)
package.json
referencing shared-ts via github url
tsconfig.json
repo: shared-ts
package.json
tsconfig.json
This setup is functional, but the process of committing to shared-ts
, building, updating the hash in package.json
, and committing again is cumbersome.
My goal is to achieve the following structure:
repo: monorepo
pdf/
package.json
reference to ../shared-ts
tsconfig.json
frontend/
package.json
reference to ../shared-ts
tsconfig.json
mobile/
package.json
reference to ../shared-ts
tsconfig.json
shared-ts/
package.json
tsconfig.json
I have attempted various approaches so far, such as:
- Using TypeScript project references, but struggling with dependencies in the shared-ts project
- Adding
in package.json, which copies shared-ts into the node_modules of each package, requiring yarn to be re-run after every change"shared-ts": "../shared-ts"
- Attempting to use
yarn link
inpostinstall
, resulting in an error message about not finding the module 'shared-ts' or its type declarations - Creating a symlink directly in
postinstall
using
, causing TypeScript to fail in finding the moduleln -s ../shared-ts/ node_modules/shared-ts/
- Exploring the option of using
npm link
inpostinstall
, despite it being slow and running into permissions issues during CI execution
Is there an efficient method to accomplish this? Any suggestions on alternative methods I could experiment with?