Watermelondb: rxjs as peer dependecy

Created on 25 Apr 2020  路  4Comments  路  Source: Nozbe/WatermelonDB

Please move rxjs into peerDependecies for both projects, watermelondb and with-observables.

Screenshot 2020-04-25 at 21 15 23

Tumbled on this because my host project uses a more recent rxjs version and typescript is complaining about a mismatch.

        Types of parameters 'subscriber' and 'subscriber' are incompatible.
          Type 'import("PROJECT_ROOT/node_modules/rxjs/internal/Subscriber").Subscriber<any>' is not assignable to type 'import("PROJECT_ROOT/node_modules/@nozbe/watermelondb/node_modules/rxjs/internal/Subscriber").Subscriber<any>'.
            Property 'isStopped' is protected but type 'Subscriber<T>' is not a class derived from 'Subscriber<T>'.

Most helpful comment

it can't be a peer dependency, because this requires users to set up the right version

Why not? it can be very well and is a common practice. Take a look a the package.json of angular/core for example

https://unpkg.com/@angular/core@9.1.9/package.json

I assume you found a fix on your side

my solution was to not use WatrermelonDB.

The issue boils down do 2 severe Problems. Both must be addressed when using WatermelonDB.

  1. fixing the type mismatch so typescript is happy. There are several ways one can do that. But this is all about silencing an issue which is correctly discovered as a problem by typescript.
  2. fixing the bundle size of the application. Since watermelondb, with-observables and my application all reference a different source of rxjs, i end up with multiple versions of rxjs in my final bundle. To avoid that i have to configure my bundling tool so that only a specific version of rxjs is taken only once.

All of this is not necessary if rxjs is a peer dependency. Users will be notified with a warning if the peer dependency ist not installed, or is installed in a wrong version. It is up to the user to continue with a wrong version. I'd suggest to reopen the issue.

All 4 comments

it can't be a peer dependency, because this requires users to set up the right version - I assume you found a fix on your side, closing

it can't be a peer dependency, because this requires users to set up the right version

Why not? it can be very well and is a common practice. Take a look a the package.json of angular/core for example

https://unpkg.com/@angular/core@9.1.9/package.json

I assume you found a fix on your side

my solution was to not use WatrermelonDB.

The issue boils down do 2 severe Problems. Both must be addressed when using WatermelonDB.

  1. fixing the type mismatch so typescript is happy. There are several ways one can do that. But this is all about silencing an issue which is correctly discovered as a problem by typescript.
  2. fixing the bundle size of the application. Since watermelondb, with-observables and my application all reference a different source of rxjs, i end up with multiple versions of rxjs in my final bundle. To avoid that i have to configure my bundling tool so that only a specific version of rxjs is taken only once.

All of this is not necessary if rxjs is a peer dependency. Users will be notified with a warning if the peer dependency ist not installed, or is installed in a wrong version. It is up to the user to continue with a wrong version. I'd suggest to reopen the issue.

@radex please 馃檹 this issue needs addressing. Please you can set rxjs version range so that installed locally can match your range, that way you only have to test the changes along the versions of rxjs if it breaks this package.

"peerDependencies": {
    ...
    "rxjs": ">=6.0.0-beta.0 <7"
    ...
  },

Or better you could update to a higher version of rxjs, that way someone could drop to the packages versions.

it can't be a peer dependency, because this requires users to set up the right version - I assume you found a fix on your side, closing

Please setting a range, or list of versions you deem are correct will go along way to help fix some serious typescript issues on out local code. Also the assume performance improvements over the course of rxjs.

I'm concerned about making the 馃崏 install even more annoying for users (who are not necessarily using TS)鈥β營f you _are_ using TS _and_ have an issue with rxjs mismatch, why not use resolutions to force WatermelonDB to use the exact same version of RxJS as your app?

As for withObservables specifying a different rxjs version - that _is_ a problem. Please send a PR to align these

Was this page helpful?
0 / 5 - 0 ratings