-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
@storybook/react - support airbnb-js-shims v1 or v2? #3955
Comments
This is still important. |
Closing “stale” issues is user-hostile; this remains important. |
I feel that What is the problem with this? |
I’d suggest telling your users to use Either way, while it is a peer dep, this issue is asking you to widen the semver range to If you want to make it both a dep and a peerDep, that should also ease users problems with it while still ensuring it’s not duplicated in the graph. |
Currently, it's not a peer (at least in v4). It's a dependency of @Hypnosphi WDYT? |
Then by making it use the semver range I’ve asked for, Airbnb can use either version, and it will be deduped out of storybook/react - there’s still a benefit. |
Yeah, I understand that making it a peer will allow us to extend the range. But I still want to get feedback of other maintainers about making it a peer. Technically, every dependency that we have, can conflict with users setup 🤷♂️ we can't make every dependency to be a peer, right? So, maybe we can solve your problem somehow else? If you are having two versions of this package in a graph, maybe you just can replace the implementation with webpack and that's all? |
Sorry for the confusion - you don’t need to make it a peer dep. If you merely make the dep be |
I can't understand how it will solve it (sry for being picky). |
Agree with @igor-dv
Telling the users to use some additional tool just to make things work doesn't sound like a good idea to me
@ljharb is probably going to rely on npm/yarn deduping. Namely, that it will pick the same version as they have in their app |
I see two other options there:
|
if the range allows v1, and v1 is already present in the tree, then npm won’t install v2. No webpack is required. Since the mention of peer deps was off topic and a misunderstanding, the (good) advice re install-peerdeps isn’t related to this thread. |
Looks like @igor-dv provided a counter-example: #3955 (comment) Anyway, even if it was like you say, it would be an optimisation not a contract you could rely on |
That’s not how it works in practice, if you have a lockfile and v1 is at the top of the tree, and then you install something that depends on “v1 || v2” then it will not install v2. It’s quite reliable; i rely on it with many packages. It’s how npm and semver work ¯\_(ツ)_/¯ |
You're a lucky man then. That doesn't make current npm behavior in that aspect a contract. My advice is to use option 1 from #3955 (comment). It will provide a guarantee. |
We need it across not just webpack, since the shims are also used in node. Its a contract npm provides since its inception. It’s a shame you don’t want to add 4 characters and no behavior change to “dependencies” to unblock Airbnb from continuing to use storybook. |
@Hypnosphi since it won't affect us, let's add this to help Airbnb friends ☺ |
@ljharb, BTW, if you could point us to any example or a blog post about this, that'd be great. Maybe it will solve us something as well |
I’m not aware of any specifically; it’s just the way npm handles its dependency graph. Shims are a unique category because they’re usually only dependencies of apps, but due to storybook’s iframes, they’re needed in this package - as such, something that would normally always be a singleton by virtue of only being defined in the top level package.json isn’t, and widening the dep range helps avoid this. Conceptually it should really be a peerDep, since it needs to be a singleton - but that causes the UX issues mentioned above, unless it’s both a peerDep and a dep. Either way, the breaking change for the shims from v1 to v2 aren’t relevant to storybook, so “^1 || ^2” is the conceptually correct range. |
Npm doesn't have lockfiles since its inception. And as demonstrated in #3955 (comment), it doesn't work like that without a pre-generated lockfile (a specific order of installation is probably also required). What's wrong with using webpack's |
@igor-dv I'd prefer not to help anyone to shoot in their feet. |
Because the semantics of it is "let npm install either v1 or v2 depending of what its optimization algorithms find reasonable". This is not exactly what you, or anyone else, need. |
The custom config you need may look like this:
I'll really appreciate if you actually try it and tell us if anything goes wrong with it. |
@Hypnosphi this is exactly what I need, and I maintain what everyone needs. Whether they have v1 or v2 won't impact storybook's code, but it will impact their application's code. The issue is that i need storybook to use v1, because my application's code uses v1. Later, when I upgrade to v2, I'll need storybook to use that. I'm not clear on how storybook's webpack config can address that, but even if that would allow me to force v1 into storybook, i'd still have an unnecessary copy of v2 installed and on disk. |
What you need is to use everywhere the version that you directly depend on (please correct me if I'm wrong). The If 64 kilobytes of disk space becomes a real issue, we can consider option 2, that is removing the polyfills and telling the users that they should provide those themselves. |
64k of disk space is far more of an issue than 5 characters in a semver range that 99% of users will never interact with. |
I never sad the characters are a problem |
Then i still don’t understand why you aren’t willing to widen the bottom end of the semver range for this dependency :-/ |
Because it isn't guaranteed to solve your issue. It most probably will, but it could break then with any npm patch release. |
It’s guaranteed to solve my issue, in my setup, with a lockfile. It wouldn’t break unless you then raised the lower bound, which you’d have no reason to do, but that’s a risk I’m happy to accept. |
OK please open a PR. Someone will definitely approve it. Sorry for being too precaucious |
I’ll try! Now that master is the v4 alpha, to where should i make a PR to get this in v3? |
@ljharb Just PR to master and we'll cherry-pick it into v3. 😄 Happy to do a release today once it's good to go. |
@shilman in master, it's in storybook/core, in v3, it's in storybook/react, but sure, np. (this is why i filed an issue in the first place instead of just opening a PR; because having master be an unreleased version makes contributing very confusing) |
Filed #4189 for v4. |
@ljharb I see--the 3.4 release branch is |
@shilman thanks, i'll open up that PR as well. |
Both PRs are now merged, thanks!! |
@ljharb Here's the first release: https://github.com/storybooks/storybook/releases/tag/v3.4.11 Let me know if that works for you, and I'll get the other one out with the other alpha changes. Fingers crossed! |
@shilman thanks, this worked perfectly and allowed the deduping we needed :-) |
It'd be great if
@storybook/react
could allow^1 || ^2
, for deduping of either.The text was updated successfully, but these errors were encountered: