fix: declare tslib ^2.1.0 in datastore-storage-adapter and notifications (__spreadArray) - #14881
Merged
ahmedhamouda78 merged 3 commits intoJul 23, 2026
Conversation
…ons (__spreadArray) @aws-amplify/datastore-storage-adapter and @aws-amplify/notifications are compiled with target es5 + downlevelIteration + importHelpers: true (via `node ./build` -> tsconfig.build.json -> tsconfig.base.json), so their emitted lib/ imports TypeScript helpers from tslib, including tslib.__spreadArray. That helper only exists in tslib >= 2.1.0. Neither package declares tslib as a dependency, so a consumer's dependency tree can resolve their tslib import to an incompatible version (e.g. tslib@1.x from a peer), producing the runtime error "__spreadArray is not a function". Same class of bug as aws-amplify#14865 (fixed for @aws-amplify/datastore in aws-amplify#14878); these two packages share datastore's exact profile (import tslib.__spreadArray, declare no tslib). Declare tslib ^2.1.0 (the exact version that introduced __spreadArray; ^2.0.0 is insufficient because 2.0.x still lacks it). Packages fixed: - @aws-amplify/datastore-storage-adapter (19 imported __spreadArray refs, no tslib dep) - @aws-amplify/notifications (4 imported __spreadArray refs, no tslib dep) Verified: __spreadArray is undefined in tslib 1.14.1/2.0.3 and a function from 2.1.0+; published artifacts import tslib.__spreadArray (19 and 4 refs); an end-to-end consumer where a peer forces tslib@1.x throws "__spreadArray is not a function" with no tslib dep and works once tslib ^2.1.0 is declared; yarn install is a no-op for yarn.lock (tslib@^2.1.0 already resolves to 2.7.0). Related: aws-amplify#14865, aws-amplify#14878
|
ahmedhamouda78
marked this pull request as ready for review
July 20, 2026 14:53
soberm
approved these changes
Jul 23, 2026
osama-rizk
approved these changes
Jul 23, 2026
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.
Summary
@aws-amplify/datastore-storage-adapterand@aws-amplify/notificationscan fail at bundle/runtime with__spreadArray is not a functionbecause their compiled output imports__spreadArrayfromtslibbut neither package declares atslibdependency — so a consumer can resolve an incompatible tslib (< 2.1). This declarestslib ^2.1.0in both.This is the same class of bug as #14865 (fixed for
@aws-amplify/datastorein #14878). These two packages share datastore's exact profile.Root cause
Both packages build via
node ./build→tsconfig.build.json→packages/tsconfig.base.json, which setstarget: es5+downlevelIteration: true+importHelpers: true. So their emittedlib//lib-esm/import TypeScript helpers fromtslib, includingtslib.__spreadArray— which only exists in tslib ≥ 2.1.0 (it is absent in tslib 1.x and 2.0.x). Neither package declares anytslibdependency, so a consumer's tree can resolve theirtslibimport to1.x(e.g. pulled in by a peer such asapollo-boost), giving__spreadArray is not a function.Example from the shipped
datastore-storage-adapter(lib/common/SQLiteUtils.js):The fix
tslib.__spreadArrayrefs@aws-amplify/datastore-storage-adaptertslib: ^2.1.0@aws-amplify/notificationstslib: ^2.1.0^2.1.0is the exact version that introduced__spreadArray;^2.0.0is insufficient because2.0.xstill lacks it. This is consistent with the rest of the monorepo (theaws-amplifymeta already depends ontslib ^2.0.0).Verification
tslib exports (runtime
typeof):__spreadArrayPublished artifacts import
tslib.__spreadArray:datastore-storage-adapter@2.0.70= 19 refs,notifications@1.6.21= 4 refs.End-to-end (real emitted
tslib_1.__spreadArray(...)shape, consumer where a peer forcestslib@1.x):1.14.1TypeError: tslib_1.__spreadArray is not a functiontslib ^2.1.0(this PR)2.8.1(own nested copy)Lockfile:
yarn installis a no-op foryarn.lock—tslib@^2.1.0already resolves totslib@2.7.0in the current lock (which has__spreadArray). In the installed workspace, both packages resolvetslib 2.7.0.Related
@aws-amplify/datastore__spreadArray is not a functionreport@aws-amplify/datastore(declaretslib ^2.1.0)