Open SLTKA opened 6 months ago
@SLTKA seems like this is related to a previously reported issue. Please refer to the last comment to work around this.
@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.
@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.
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 othersTo Reproduce
run
npx create-sitecore-jss@21.7.1 nextjs
remove package-lock file runyarn
using yarn v1.22.x runyarn 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 https://github.com/yarnpkg/yarn/issues/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 beshould be lenient.
(https://nodejs.org/en/blog/npm/peer-dependencies).Possible Fix
No response
Provide environment information