discussion/fix: powersync/common dependencies#847
Draft
stevensJourney wants to merge 3 commits intomainfrom
Draft
discussion/fix: powersync/common dependencies#847stevensJourney wants to merge 3 commits intomainfrom
stevensJourney wants to merge 3 commits intomainfrom
Conversation
🦋 Changeset detectedLatest commit: 632ed5c The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
We've seen a few reports of mismatched
@powersync/commonpackages in users' applications:This causes cryptic TypeScript build errors of the form
While there are multiple factors which can contribute to these package mismatches - one of the primary factors is the upgrade/bumping of
@powersync/*NPM packages in an application. The method in which the package manager facilitates these upgrades, currently can easily result in multiple versions of@powersync/commonbeing present in a project.One path which results in issues is:
@powersync/web@1.0.1(which depends on@powersync/common@1.0.1). Project also depends on@powersync/react@1.1.1which has a peerDependency range for@powersync/common@^1.0.1)@powersync/web@1.5.0which depends on@powersync/common@1.5.0. The upgrade path does not bump the common dependency for@powersync/reactwhich causes both@powersync/common@1.5.0and@powersync/common@1.0.1to be present in the project.@powersync/commonpackage cause TypeScript build errorsThe general desired behaviour is for
@powersync/webto "provide"@powersync/common, where packages such as@powersync/reactshould use the version provided by@powersync/web.The crux of the issue above is that: upgrading
@powersync/webdoes not bump the@powersync/commonversion used by@powersync/react.After some investigation, this erroneous behaviour seems to be caused by the current relationship of
@powersync/weband@powersync/common. In #179,@powersync/commonwas declared as apeerDependencyof@powersync/web. I believe the reasoning was to allow for warning if the actual resolved version of@powersync/commonwas incompatible with the SDK... ThepeerDependencyshould provide warnings, while the directdependencyshould actually dictate which version of@powersync/commonwas required.However, declaring the
peerDependencyfor@powersync/commonseems to be root cause of the issues described above, where thepeerDependencyseems to cause bumps in@powersync/webnot to bump@powersync/common- at least with PNPM10.28.2.A video which demonstrates this behaviour is below
2026-02-11_powersync_js_peerDependencies.mp4
When testing with local publishing, removing the
peerDependencydeclarations for@powersync/commonseems to fix the core issues.The benefit of having
@powersync/commonas apeerDependency(in addition to a dependency) seems to be small - if not non-existent. The fact that@powersync/webhas a direct dependency for@powersync/commonshould result in that peerDependency range always being specified, even if there are mulitiple packages which have direct dependencies for@powersync/commonAdditional tests were performed to test various future scenarios:
If a user had an older version of
@powersync/react-native(which still had peerDependency declarations) and only upgraded@powersync/web(which will no longer contain peerDependency declarations). The@powersync/webdeclaration will drive the version of@powersync/common# Web has no peer, old RN has peer ❯ pnpm why @powersync/common Legend: production dependency, optional only, dev only versions@1.0.0 /private/tmp/versions dependencies: @powersync/drizzle-driver 0.7.2 └── @powersync/common 1.47.0 peer @powersync/react-native 1.17.0 ├── @powersync/common 1.47.0 peer └─┬ @powersync/react 1.5.1 └── @powersync/common 1.47.0 peer @powersync/web 1.33.2 └── @powersync/common 1.47.0If we (only) removed the
peerDependencyrequirement for both@powersync/react-nativeand@powersync/web. Each package would have a fixed dependency range for@powersync/commonwhich could result in multiple versions of@powersync/commonbeing present.# Both have no peer, RN relies on older version ❯ pnpm why @powersync/common Legend: production dependency, optional only, dev only versions@1.0.0 /private/tmp/versions dependencies: @powersync/drizzle-driver 0.7.2 └── @powersync/common 1.47.0 peer @powersync/react-native 1.30.0 ├── @powersync/common 1.46.0 └─┬ @powersync/react 1.8.2 └── @powersync/common 1.46.0 peer @powersync/web 1.33.3 └── @powersync/common 1.47.0If we update the direct dependencies from
Then, updating only
@powersync/webdoes not automatically bump@powersync/commonfor@powersync/react-nativeBut, running
pnpm upgradewill resolve both to a single version of@powersync/common