Skip to content

fix(aws-amplify): preserve library options on partial configure#14815

Open
ShrutiPundir17 wants to merge 5 commits into
aws-amplify:mainfrom
ShrutiPundir17:fix/preserve-library-options-on-reconfigure
Open

fix(aws-amplify): preserve library options on partial configure#14815
ShrutiPundir17 wants to merge 5 commits into
aws-amplify:mainfrom
ShrutiPundir17:fix/preserve-library-options-on-reconfigure

Conversation

@ShrutiPundir17
Copy link
Copy Markdown

@ShrutiPundir17 ShrutiPundir17 commented May 14, 2026

Merge existing Amplify.libraryOptions when DefaultAmplify.configure is called with partial libraryOptions after Auth was already set up, so keys like Storage are not dropped. Pin Auth last so default Cognito providers stay intact.

Add regression test for Storage + subsequent partial reconfigure (e.g. ssr: true).

Use rimraf --glob for clean:size patterns (dual-publish-tmp, tmp*) so clean works on Windows with rimraf v6.

Description of changes

Behavior (aws-amplify)

  • Root cause: @aws-amplify/core replaces libraryOptions whenever a new object is passed to Amplify.configure. In DefaultAmplify.configure, after Auth had already been configured with default Cognito providers, a follow-up call with partial libraryOptions (e.g. only { ssr: true }) built { Auth: authLibraryOptions, ...libraryOptions }, which omitted keys that existed only on the previous Amplify.libraryOptions (e.g. Storage).
  • Fix: When merging into that path, pass
    { ...Amplify.libraryOptions, ...libraryOptions, Auth: authLibraryOptions }
    so prior category options are preserved, new options apply on top, and Auth is set last so default Cognito providers are not accidentally dropped (including Auth: undefined from a spread).

Tests

  • Updated existing initSingleton expectations to snapshot Auth before configure where the test mock mutates singleton state.
  • Added regression: Storage pre-seeded on Amplify.libraryOptions, then configure(..., { ssr: true }) — asserts Storage, ssr, and Auth are all forwarded to Amplify.configure.

Tooling (Windows + rimraf v6)

  • clean:size used rimraf dual-publish-tmp tmp* without --glob, so tmp* was treated as a literal path and failed on Windows (EINVAL). Updated to rimraf --glob dual-publish-tmp tmp* in affected package package.json files.

Issue #, if available

None filed for this specific regression. I can open an issue and link it if maintainers prefer a tracked ticket; otherwise this PR documents the bug and fix.

Description of how you validated changes

  • Unit tests: packages/aws-amplifyjest __tests__/initSingleton.test.ts (via repo-root hoisted jest). Result: all tests in that file passed, including the new regression.
  • Build (scoped): yarn turbo run build --filter=aws-amplifypassed after the rimraf --glob clean:size change (previously failed on Windows during @aws-amplify/core clean).

Full monorepo yarn test was not run in this contribution window.

Checklist

  • PR description included
  • yarn test passes
  • Unit Tests are changed or added
  • Relevant documentation is changed or added (and PR referenced)

Checklist for repo maintainers

  • Verify E2E tests for existing workflows are working as expected or add E2E tests for newly added workflows
  • New source file paths included in this PR have been added to CODEOWNERS, if appropriate

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Merge existing Amplify.libraryOptions when DefaultAmplify.configure is called with partial libraryOptions after Auth was already set up, so keys like Storage are not dropped. Pin Auth last so default Cognito providers stay intact.

Add regression test for Storage + subsequent partial reconfigure (e.g. ssr: true).

Use rimraf --glob for clean:size patterns (dual-publish-tmp, tmp*) so clean works on Windows with rimraf v6.

Co-authored-by: Cursor <cursoragent@cursor.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 14, 2026

⚠️ No Changeset found

Latest commit: bb2cc77

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Co-authored-by: Cursor <cursoragent@cursor.com>
ShrutiPundir17 added a commit to ShrutiPundir17/amplify-js that referenced this pull request May 19, 2026
Remove libraryOptions merge from initSingleton; that belongs in aws-amplify#14815.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant