Skip to content

Conversation

longlho
Copy link
Member

@longlho longlho commented Sep 7, 2020

No description provided.

@longlho longlho merged commit c2fac57 into main Sep 8, 2020
@longlho longlho deleted the peer branch September 8, 2020 02:05
@chrisbobbe
Copy link

chrisbobbe commented Oct 22, 2020

Hmm, this might have been better released as a breaking change, instead of in the patch release 5.8.1. Having routinely bumped up the version of react-intl to its latest 5.x, I'm suddenly required to install TypeScript as a direct dependency, even though I don't use TypeScript at all (I use Flow).

peerDependencies are generally considered to be part of a package's public API: semver/semver#502 (comment).

@longlho
Copy link
Member Author

longlho commented Oct 22, 2020

Hmm why are you required to?

@chrisbobbe
Copy link

chrisbobbe commented Oct 22, 2020

I'm required to add typescript to my own project's dependencies or devDependencies because typescript was added under peerDependencies in this PR.

Additionally, when I do add it, I'm required to use a version within the specific range of "3.8 || 4". This is currently impossible for me, because another package I'm using lists typescript under its peerDependencies, but with a range that doesn't intersect with that range.

Concretely, after upgrading react-intl, I get this warning when I remove node_modules and run yarn:

warning " > react-intl@5.8.6" has incorrect peer dependency "typescript@3.8 || 4".

@longlho
Copy link
Member Author

longlho commented Oct 22, 2020

Yeah you can ignore the warning

@chrisbobbe
Copy link

chrisbobbe commented Oct 22, 2020

Additionally, when I do add it, I'm required to use a version within the specific range of "3.8 || 4". This is currently impossible for me, because another package I'm using lists typescript under its peerDependencies, but with a range that doesn't intersect with that range.

This isn't necessarily react-intl's fault—I generally assume there's a valid reason for a specific version range to be given for a peer dependency. So I'm currently analyzing whether it's better for my project (for the time being) to stay on react-intl 5.8.0, or use a different version of that other package. But I would more expect to have to do this exercise as part of a major-version upgrade of react-intl, not a patch- or minor-version upgrade.

@chrisbobbe
Copy link

chrisbobbe commented Oct 22, 2020

Yeah you can ignore the warning

I'd prefer not to. The warning is there for a reason: react-intl has made an assertion about what my project's dependencies must include, and respecting that assertion is the natural thing to do.

We've found our project to be much more stable when we don't just ignore or paper over warnings, including peer-dependency warnings. One of our highest priorities is making it easy for new contributors to get started—and letting lots of warnings accumulate in a routine setup step like yarn just adds unnecessary confusion.

@longlho
Copy link
Member Author

longlho commented Oct 22, 2020

Up to you

chrisbobbe added a commit to chrisbobbe/zulip-mobile that referenced this pull request Oct 22, 2020
The upgrade guides for v4 [1] and v5 [2] are pretty short and
simple, so, might as well jump to the latest all at once.

Well, not quite the latest -- with 5.8.1 and following, `react-intl`
has `typescript` as a peer dependency, with the range "3.8 || 4".
Unfortunately, this range is disjoint with another peer-dep range
that caused us to add `typescript` in the first place; see
78daeb6. (See also
formatjs/formatjs#2067 (comment)
for a `react-intl` maintainer's flippant response to the idea of
using peer dependencies correctly.) So, use 5.8.0 precisely.

With v4 (and continuing into v5), we get a big stroke of luck for
the libdef. There's a single TypeScript file that contains all the
necessary types [3], so we only need to run Flowgen once, on that
one file. This saves a lot of the kind of work we had to do for v3.

The v4 declared breaking changes don't apply to us.

One v5 breaking change applies to us:

- `FormattedMessage` render prop is no longer variadic.

We've only ever cared about the first argument passed to the render
prop, so, grab just that one, to minimally handle the API change. In
fact, it seems like a bug that we're not paying attention to any
others that are passed. But it looks like no others are being
passed, currently; we haven't explicitly made that happen. But we'll
stop using this confusing pattern in an upcoming commit; see
discussion [4].

[1] https://formatjs.io/docs/react-intl/upgrade-guide-4x
[2] https://formatjs.io/docs/react-intl/upgrade-guide-5x
[3] except for React, which is normal, and which we'll address to
    some extent in the next commit.
[4] zulip#4222 (comment)
chrisbobbe added a commit to chrisbobbe/zulip-mobile that referenced this pull request Oct 22, 2020
The upgrade guides for v4 [1] and v5 [2] are pretty short and
simple, so, might as well jump to the latest all at once.

Well, not quite the latest -- with 5.8.1 and following, `react-intl`
has `typescript` as a peer dependency, with the range "3.8 || 4".
Unfortunately, this range is disjoint with another peer-dep range
that caused us to add `typescript` in the first place; see
78daeb6. (See also
formatjs/formatjs#2067 (comment)
for a `react-intl` maintainer's flippant response to the idea of
using peer dependencies correctly.) So, use 5.8.0 precisely.

With v4 (and continuing into v5), we get a big stroke of luck for
the libdef. There's a single TypeScript file that contains all the
necessary types [3], so we only need to run Flowgen once, on that
one file. This saves a lot of the kind of work we had to do for v3.

The v4 declared breaking changes don't apply to us.

One v5 breaking change applies to us:

- `FormattedMessage` render prop is no longer variadic.

We've only ever cared about the first argument passed to the render
prop, so, grab just that one, to minimally handle the API change. In
fact, it seems like a bug that we're not paying attention to any
others that are passed. But it looks like no others are being
passed, currently; we haven't explicitly made that happen. But we'll
stop using this confusing pattern in an upcoming commit; see
discussion [4].

[1] https://formatjs.io/docs/react-intl/upgrade-guide-4x
[2] https://formatjs.io/docs/react-intl/upgrade-guide-5x
[3] except for React, which is normal, and which we'll address to
    some extent in the next commit.
[4] zulip#4222 (comment)
@longlho
Copy link
Member Author

longlho commented Oct 22, 2020

Or rather let's put it this way: do you have an alternative solution?

Bumping major version doesn't solve this problem.

@chrisbobbe
Copy link

chrisbobbe commented Oct 22, 2020

Bumping major version doesn't solve this problem.

I appreciate it when packages wait for a major-version release to make a public API change. Is this where you disagree? Or would you say that introducing peer-dependency constraints, or dropping previously valid versions from a peer dependency's version range, are not public API changes? Above, I linked to a discussion of that question: semver/semver#502 (comment)

@longlho
Copy link
Member Author

longlho commented Oct 22, 2020

Those are not public API changes. We don't bump major when we drop node 8, or react 16.3, or old CLDR dataset

@chrisbobbe
Copy link

chrisbobbe commented Oct 22, 2020

Those are not public API changes. We don't bump major when we drop node 8, or react 16.3, or old CLDR dataset

Since you're reasoning from react-intl's habits, and not from principles (or even from other projects' habits), I understand your argument not as "these are not public API changes", but as "these are not public API changes for react-intl"—that is, react-intl's particular policy is to make this kind of breaking change (and some other kinds, apparently) at random. I'll keep a mental note of it; I'm always careful when I take dependencies' new versions, but I'll start treating react-intl's with extra skepticism and distrust.

@longlho
Copy link
Member Author

longlho commented Oct 22, 2020

Yes you should always pin to a specific version instead of taking ranges and run you test suite when you upgrade.

chrisbobbe added a commit to chrisbobbe/zulip-mobile that referenced this pull request Oct 23, 2020
The upgrade guides for v4 [1] and v5 [2] are pretty short and
simple, so, might as well jump to the latest (currently 5.8.6) all
at once.

We restrict the version range to that single version (instead of
using a caret or a tilde), since `react-intl` doesn't invite its
users to expect breaking changes to be handled well [3]. We also
change our useless `typescript` dev-dependency's version to a range
that's in the intersection of the range `react-intl` gives for it,
and the range we found in 78daeb6.

With v4 (and continuing into v5), we get a big stroke of luck for
the libdef. There's a single TypeScript file that contains all the
necessary types [4], so we only need to run Flowgen once, on that
one file. This saves a lot of the kind of work we had to do for v3.

The v4 declared breaking changes don't apply to us.

One v5 breaking change applies to us:

- `FormattedMessage` render prop is no longer variadic.

We've only ever cared about the first argument passed to the render
prop, so, grab just that one, to minimally handle the API change. In
fact, it seems like a bug that we're not paying attention to any
others that are passed. But it looks like no others are being
passed, currently; we haven't explicitly made that happen. But we'll
stop using this confusing pattern in an upcoming commit; see
discussion [5].

[1] https://formatjs.io/docs/react-intl/upgrade-guide-4x

[2] https://formatjs.io/docs/react-intl/upgrade-guide-5x

[3] formatjs/formatjs#2067 (comment)

[4] except for React, which is normal, and which we'll address to
    some extent in the next commit.

[5] zulip#4222 (comment)
gnprice pushed a commit to chrisbobbe/zulip-mobile that referenced this pull request Oct 23, 2020
The upgrade guides for v4 [1] and v5 [2] are pretty short and
simple, so, might as well jump to the latest (currently 5.8.6) all
at once.

We restrict the version range to that single version (instead of
using a caret or a tilde), since `react-intl` doesn't invite its
users to expect breaking changes to be handled well [3]. We also
change our useless `typescript` dev-dependency's version to a range
that's in the intersection of the range `react-intl` gives for it,
and the range we found in 78daeb6.

With v4 (and continuing into v5), we get a big stroke of luck for
the libdef. There's a single TypeScript file that contains all the
necessary types [4], so we only need to run Flowgen once, on that
one file. This saves a lot of the kind of work we had to do for v3.

The v4 declared breaking changes don't apply to us.

One v5 breaking change applies to us:

- `FormattedMessage` render prop is no longer variadic.

We've only ever cared about the first argument passed to the render
prop, so, grab just that one, to minimally handle the API change. In
fact, it seems like a bug that we're not paying attention to any
others that are passed. But it looks like no others are being
passed, currently; we haven't explicitly made that happen. But we'll
stop using this confusing pattern in an upcoming commit; see
discussion [5].

[1] https://formatjs.io/docs/react-intl/upgrade-guide-4x

[2] https://formatjs.io/docs/react-intl/upgrade-guide-5x

[3] formatjs/formatjs#2067 (comment)

[4] except for React, which is normal, and which we'll address to
    some extent in the next commit.

[5] zulip#4222 (comment)
chrisbobbe added a commit to chrisbobbe/zulip-mobile that referenced this pull request Jun 8, 2021
Like in 8038528, we restrict the version range to that single
version (instead of using a caret or a tilde), since `react-intl`
doesn't invite users to expect them to handle breaking changes
well [1].

There's no particular change we're interested in right now; we just
want to upgrade for the sake of upgrading. Nothing stands out in the
changelog [2] as being a breaking change, but we don't really trust
the package, as mentioned, so the easiest way to discover any will
probably be to have it out in a beta for a little while.

[1] formatjs/formatjs#2067 (comment).
[2] https://github.com/formatjs/formatjs/blob/main/packages/react-intl/CHANGELOG.md
chrisbobbe added a commit to chrisbobbe/zulip-mobile that referenced this pull request Jun 8, 2021
Like in 8038528, we restrict the version range to that single
version (instead of using a caret or a tilde), since `react-intl`
doesn't invite users to expect them to handle breaking changes
well [1].

There's no particular change we're interested in right now; we just
want to upgrade for the sake of upgrading. Nothing stands out in the
changelog [2] as being a breaking change, but we don't really trust
the package, as mentioned, so the easiest way to discover any will
probably be to have it out in a beta for a little while.

[1] formatjs/formatjs#2067 (comment).
[2] https://github.com/formatjs/formatjs/blob/main/packages/react-intl/CHANGELOG.md
chrisbobbe added a commit to chrisbobbe/zulip-mobile that referenced this pull request Jun 9, 2021
Like in 8038528, we restrict the version range to that single
version (instead of using a caret or a tilde), since `react-intl`
doesn't invite users to expect them to handle breaking changes
well [1].

There's no particular change we're interested in right now; we just
want to upgrade for the sake of upgrading. Nothing stands out in the
changelog [2] as being a breaking change, but we don't really trust
the package, as mentioned, so the easiest way to discover any will
probably be to have it out in a beta for a little while.

I did test switching to a different language, and things didn't seem
to break when I did that.

[1] formatjs/formatjs#2067 (comment).
[2] https://github.com/formatjs/formatjs/blob/main/packages/react-intl/CHANGELOG.md
chrisbobbe added a commit to chrisbobbe/zulip-mobile that referenced this pull request Jun 11, 2021
Like in 8038528, we restrict the version range to that single
version (instead of using a caret or a tilde), since `react-intl`
doesn't invite users to expect them to handle breaking changes
well [1].

There's no particular change we're interested in right now; we just
want to upgrade for the sake of upgrading. Nothing stands out in the
changelog [2] as being a breaking change, but we don't really trust
the package, as mentioned, so the easiest way to discover any will
probably be to have it out in a beta for a little while.

I did test switching to a different language, and things didn't seem
to break when I did that.

[1] formatjs/formatjs#2067 (comment).
[2] https://github.com/formatjs/formatjs/blob/main/packages/react-intl/CHANGELOG.md
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.

3 participants