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

[nextjs] Fix build errors when app uses personalize initializer, add utils, site submodule exports #1430

Merged
merged 6 commits into from
Apr 13, 2023

Conversation

art-alexeyenko
Copy link
Contributor

Description / Motivation

NextJS version 13.3 has fixed some issues related to server imports in client context. This has caused some errors to occur when an import in a client component would also cause nextjs/server to be imported, like this one: vercel/next.js#48251
This PR moves SiteInfo, SiteResolver and tryParseEnvValue exports from '@sitecore-jss/sitecore-jss-nextjs/middleware' to separate submodules, in order to avoid these imports dragging server logic into a client bundle during build.

It's also possible to fix this issue by adding a next-config plugin to patch webpack configuration in a sample app. The patch would prevent loading 'fs' in client context (this would be a non-breaking approach), but that would be more of a workaround than a future-proof fix.

Testing Details

  • Unit Test Added
  • Manual Test/Other (Please elaborate) - app builds without error with the changes applied

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

@art-alexeyenko art-alexeyenko requested a review from a team April 11, 2023 23:44
@art-alexeyenko art-alexeyenko requested a review from ambrauer April 12, 2023 17:31
@art-alexeyenko art-alexeyenko requested a review from ambrauer April 12, 2023 18:44
Copy link
Contributor

@ambrauer ambrauer left a comment

Choose a reason for hiding this comment

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

Looks good to me, nice work 👍

@art-alexeyenko art-alexeyenko changed the title [nextjs] Fix build errors when app uses personalize initializer [nextjs] Fix build errors when app uses personalize initializer, add utils, site submodule exports Apr 13, 2023
@art-alexeyenko art-alexeyenko merged commit 7575511 into dev Apr 13, 2023
@art-alexeyenko art-alexeyenko deleted the bug/580975-create-nextjs-fails branch April 13, 2023 15:28
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.

2 participants