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

In React Native, how can you make changes to a local library from within your main project without having to compile the former

$
0
0

The setup:

./company/MyApp  ./company/MyLibrary

The desired workflow would be:

  • Working on MyApp using e.g. VSCode
  • Having MyLibrary as dependency to MyApp
  • Make a change to MyLibrary without having to recompile
  • Make a change to MyLibrary without needing any services that detect this change
  • MyApp bundles correctly using Metro
  • Making changes to MyLibrary whilst the app is running will hot reload the app

What I have tried so far:

Using yarn link or npm link:

  • cannot confirm that symlinked dependency is referenced from within the project by looking at the node_modules directory
  • read that Metro bundler doesn't recognise symlinks (unconfirmed)
  • stopped trying at this point, but can imagine that the dependency would still need to be compiled before changes are available to MyApp

Using WML

Works, but is cumbersome.Installation:

  • Install watchman
  • Install wml globally using yarn global add wml
  • Run watchman watch /Users/[your username]/.config/yarn/global/node_modules/wml/src(or wherever wml is installed
  • Run wml add ~/my-package ~/main-project/node_modules/my-package
  • Run wml start

Workflow:

  • Run cd company/MyApp
  • Run wml start
  • Run yarn android:run (or whatever your platform and script name is)
  • Make changes to MyLib
  • Run (cd ../MyLibrary && tsc)
  • The app hot reloads with the latest changes from MyLib

However, this workflow doesn't fulfil several desired requirements:

  • Make a change to MyLibrary without having to recompile
  • Make a change to MyLibrary without needing any services that detect this change

Question:

How can you make changes to a local library from within your main project without having to compile the former or run any services that detect this change?


Viewing all articles
Browse latest Browse all 6287

Trending Articles



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