Search code examples
fluttersupabasedart-pubsupabase-fluttermelos

How to debug the supabase_flutter repository and other melos based monorepos locally?


I'm trying to debug the supabase_flutter repository locally. Their is some functionality within the packages, that I can test best within an app I'm working on. Therefore I'm trying to use the local repo as a dependency within the pubspec.yaml of my app.

I already forked and cloned the repo to my local machine, initialized everything with melos and added the local package as an dependency according to the README.

When I'm trying to inspect an imported function in my app from the package 'supabase_flutter', the related local file of the repo opens as expected. But when I'm trying to inspect a function from the 'postgrest' package, I only get send to a copy of the file in the .pub-cache directory.

This means, that I am unable to test any changes I make to files of the 'postgrest' package in my app, because the copied file in the .pub-cache directory doesn't get updated. I can only debug changes that I make to the 'supabase_flutter' package, like adding a print statement to the Supabase.initialize function. My initial goal was to debug the PostgrestTransformBuilder<T> range(int from, int to, {String? referencedTable}) function at packages/postgrest/lib/src/postgrest_transform_builder.dart and add a print statement there.

I already tried different combinations of pub get, pub upgrade and melos bootstrap together with deleting the .pub-cache directory multiple times.


Solution

  • This is not a Supabase-specific question, but rather a question of how the Dart packaging system works.

    Add the following in your pubspec.yaml file

    melos_managed_dependency_overrides: functions_client,gotrue,postgrest,realtime_client,storage_client,yet_another_json_isolate
    dependency_overrides:
      functions_client:
        path: ../supabase-flutter/packages/functions_client
      gotrue:
        path: ../supabase-flutter/packages/gotrue
      postgrest:
        path: ../supabase-flutter/packages/postgrest
      realtime_client:
        path: ../supabase-flutter/packages/realtime_client
      storage_client:
        path: ../supabase-flutter/packages/storage_client
      supabase:
        path: ../supabase-flutter/packages/supabase
      yet_another_json_isolate:
        path: ../supabase-flutter/packages/yet_another_json_isolate
      supabase_flutter:
        path: ../supabase-flutter/packages/supabase_flutter
    
    

    Then I would try the following:

    • Delete the pubspec.lock file in your Flutter app
    • Run melos bs in the supabase_flutter package
    • Run pub get in your Flutter app
    • Verify in your pubspec.lock file in your Flutter app that it is using the local version of the dependencies.