Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(@aws-amplify/datastore): nextjs/swc broken build workaround #10765

Merged
merged 8 commits into from Dec 13, 2022

Conversation

svidgen
Copy link
Contributor

@svidgen svidgen commented Dec 12, 2022

Description of changes

NextJS 13 enables SWC by default, which sometimes mangles the the build. This PR does two things:

  1. Adds integ tests for sample apps that attempt to trigger bad nextjs builds
  2. Adds a workaround for one known case, where SWC was over-aggressively dropping a variable declaration, resulting in an exception several lines later.

Note: Depends on https://github.com/aws-amplify/amplify-js-samples-staging/pull/494

Issue #, if available

#10732

Description of how you validated changes

Runtime failures were seen as in #10732 with NextJS@13 prod builds. The breakage was isolated by inserting dummy console logs with unique strings to help us determine where we were in the resulting minified build. By doing so, we could see that a variable declaration and later assignment were being eliminated entirely. Setting the var to a default value caused SWC to leave the declaration in and resolved runtime issues.

One of the newly added integ tests (the "basic" one) successfully triggers the error in CI on prod builds without the fix. The fix makes it pass in CI.

Checklist

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

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

@svidgen svidgen requested review from a team as code owners December 12, 2022 18:14
jimblanc
jimblanc previously approved these changes Dec 12, 2022
.circleci/config.yml Outdated Show resolved Hide resolved
.circleci/config.yml Outdated Show resolved Hide resolved
Copy link
Contributor

@iartemiev iartemiev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍🏻

@svidgen svidgen merged commit 24978b4 into main Dec 13, 2022
@dpilch dpilch deleted the ds-nextjs-workaround branch December 21, 2022 20:45
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.

None yet

5 participants