-
Notifications
You must be signed in to change notification settings - Fork 82
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
Consider using peerDependencies
for LWC
#349
Comments
For some context, when we first created this package, we took into account the typical user who may not know how to manage dependencies. That said, we haven't really done a good job of keeping the LWC version up to date, outside of promoting |
Yeah it also calls into question whether we would keep the existing |
So in short, the customer adoption story would be:
For new customers, the flow would be: yarn add -D \
@salesforce/sfdx-lwc-jest@winter24 \
lwc@winter24 # <-- this is new (For |
I don't think this is too big of a lift to ask for. |
@jamessimone Correct, yes. That will not change. The only change is that consumers of |
yeah, I mean, I'm always in favor of explicitly being able to control/pin dependencies. This seems like a net win! |
@nolanlawson if your proposal went ahead, we would no longer need to install yarn add -D \
@salesforce/[email protected] \ # <-- this version/tag is no longer tied to a Salesforce release
lwc@winter24 # <-- this is new |
@pozil Sadly yes, you would still need the correct release tag for First, there is the Line 47 in 37d0f0b
Second, there are the lightning-stubs which do occasionally change release-to-release. Perhaps we can find some other way to determine the |
Alternatively, we could get rid of sfdx-lwc-jest/src/utils/test-runner.js Lines 24 to 28 in 37d0f0b
|
We (LWC team) talked about this, and concluded:
|
Looking into this more deeply, we may not even need to convert to ESM or change to a single This project doesn't actually rely on any LWC dependencies (other than The only reliance is here: Lines 79 to 81 in c3ace89
So this basically instructs Jest that, if it sees the So essentially, consumers of this package should just be able to install There are no issues with bundlers/tools that complain about importing implicit transitive dependencies (e.g. Yarn Berry), because if you were able to import The main thing we will need to do is update SF cli so that a new project is templated with both We will also need to do a major version bump and explain that you have to install We should also get rid of the |
@nolanlawson sounds like a solid plan. I think the only remaining issue is that we would theoretically be losing the ability to poke the user into updating their version every release. @pozil do you have more context on the purpose of the |
@ekashida I would remove this check. I agree with @nolanlawson, I never saw the value of this check. |
I forgot to mention that one of the main drivers for disabling this check was the fact that we often were waiting for a new version of |
We can drop the check even without refactoring our LWC dependencies. Based your feedback @pozil I would accept a PR that simply did that. 🙂 |
@nolanlawson I took your offer and submitted PR #370 😉 |
Now that #370 is merged, I think the next step is just to make |
OK now that I look at this, So it's already the case that you need particular versions of those deps when using |
Currently
@salesforce/sfdx-lwc-jest
has an explicit dependency on these core LWC packages:@lwc/compiler
@lwc/engine-dom
@lwc/engine-server
@lwc/module-resolver
@lwc/synthetic-shadow
@lwc/wire-service
And these lwc-test packages:
@lwc/jest-preset
@lwc/jest-resolver
@lwc/jest-serializer
@lwc/jest-transformer
I've seen cases where a repo ends up with mixed LWC dependencies, due to
@salesforce/sfdx-lwc-jest
bringing in its own version of LWC, in addition to 1) direct dependencies on LWC, and 2) dependencies from other meta-packages (like LWR). This can lead to version mismatch errors where a component is compiled with one version of LWC and run through another version's runtime.It's less of an issue for the
lwc-test
dependencies, but it could still happen.Arguably we could use
peerDependencies
for the above – at least for the core LWC packages. This would be a breaking change, since consumers would now need to install their own version of LWC on top of@salesforce/sfdx-lwc-jest
.We could ease the burden by requiring only the
lwc
package to be installed, but this would require changing all the imports from e.g.@lwc/engine-dom
tolwc/engine-dom
. The same may need to be done for@lwc/jest-*
, which does usepeerDependencies
already.The text was updated successfully, but these errors were encountered: