Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

Sharing a typescript library in a monorepo

$
0
0

I'm trying to setup a monorepo with 3 services sharing some library code.

This is the current situation:

repo: webpdf/  package.json    reference to shared-ts using github url  tsconfig.jsonfrontend/  package.json    reference to shared-ts using github url  tsconfig.json
repo: mobile (react-native)  package.json    reference to shared-ts using github url  tsconfig.json
repo: shared-ts  package.json  tsconfig.json

This works but it's a pain to commit to shared-ts, build, change the hash in package.json and commit again.

This is what I'd like to achieve:

repo: monorepopdf/  package.json    reference to ../shared-ts  tsconfig.jsonfrontend/  package.json    reference to ../shared-ts  tsconfig.jsonmobile/  package.json    reference to ../shared-ts  tsconfig.jsonshared-ts/  package.json  tsconfig.json

So far I've tried:

  • TypeScript project references, but it seems like there is no way to have dependencies in the shared-ts project
  • "shared-ts": "../shared-ts" in package.json but it copies shared-ts into the node_modules of each package so I have to re-run yarn everytime I make a change
  • yarn link in postinstall: error TS2307: Cannot find module 'shared-ts' or its corresponding type declarations.
  • creating a symlink directly in postinstall with ln -s ../shared-ts/ node_modules/shared-ts/ but it seems TypeScript fails to find the module
  • npm link in postinstall seems like the most promising but it's really slow and I'm having trouble running it in CI because of some permissions issues.

Is there a good way of doing this? Any ideas on other things I could try?


Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>