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 template not building with Yarn #1789

Open
SLTKA opened this issue May 3, 2024 · 3 comments
Open

NextJs template not building with Yarn #1789

SLTKA opened this issue May 3, 2024 · 3 comments
Labels
backlog Issue/PR/discussion is reviewed and added to backlog for the further work 🐞 bug

Comments

@SLTKA
Copy link

SLTKA commented May 3, 2024

Describe the Bug

When using YARN instead of NPM on freshly created NextJS template (using create-sitecore-jss) it fails to build due to missing dependencies. Tested with 21.7.1.
missing modules @sitecore-feaas/clientside and others

To Reproduce

run
npx create-sitecore-jss@21.7.1 nextjs
remove package-lock file
run yarn using yarn v1.22.x
run yarn start:connected

Expected Behavior

Yarn 1.x doesn't handle peerDependencies on imported packages and require them to be listed as dev or normal dependencies yarnpkg/yarn#1503

NextJS Template should explicitly install all Peer Dependencies (as it was before in 21.6.3) OR all peerDependencies should be optional and not use require in bundled code. At the same time version of deps should be should be lenient. (https://nodejs.org/en/blog/npm/peer-dependencies).

Possible Fix

No response

Provide environment information

  • Sitecore Version: 10.3
  • JSS Version: 21.7.1
  • Browser Name and version: N/A
  • Operating System and version (desktop or mobile): Windows, yarn v1.22.21
  • Link to your project (if available):
@SLTKA SLTKA added the 🐞 bug label May 3, 2024
@addy-pathania
Copy link
Contributor

addy-pathania commented May 16, 2024

@SLTKA seems like this is related to a previously reported issue. Please refer to the last comment to work around this.

@SLTKA
Copy link
Author

SLTKA commented May 17, 2024

@SLTKA seems like this is related to a previously reported issue. Please refer to the last comment to work around this.

Hi @sc-addypathania thank you for the link. I'm not sure how this helps with yarn 1.x which always works as npm would with legacy-peer-deps flag and there is no option to change this.

One obvious solution would be to use npm instead of yarn and we would not have any issue. Or add missing things manually (which we did), but both approaches are not resolving the core issue on this bug report.

Below is just an opinion please don't read it as any guidance or desire for action:

Consumer (the sample projects) of packages need to ensure that they install all peer dependencies. Other dependencies should be TRULY optional and should not cause any issue (which is not the case now). On the other hand, peer dependencies can be still required (not optional), so possibly you need to consider including what is not optional into package.json's dependencies or devDependencies lists (like it was before, but "optimized" in recent versions) to ensure that those peers installed correctly.

In summary, peerDependancies of your package should be explicitly visible in consumer's package.json to ensure consumers well aware of versions they selected for them since you delegated control to them (by using peer and not default dependencies). What is not there should not demand installation and code should handle absence of the package safely.

The other way is to ignore people preferences on package manager and to clearly document that other (not npm) package manages are not supported with your solution.

@addy-pathania
Copy link
Contributor

@SLTKA I understand your concern now. I have added this to our backlog, we will soon make a decision on how to handle this issue with yarn.

@addy-pathania addy-pathania added the backlog Issue/PR/discussion is reviewed and added to backlog for the further work label May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog Issue/PR/discussion is reviewed and added to backlog for the further work 🐞 bug
Projects
None yet
Development

No branches or pull requests

2 participants