question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Use peer dependencies

See original GitHub issue

The discussion of peer dependencies in #129 got me thinking - what do you think about moving react-i18next, i18next (and perhaps other associated i18next packages), and react to dev dependencies and also including them as peer dependencies (much like the next-i18next package does with i18next and react)? It would help communicate minimum compatible versions of each package and would help us avoid yarn warnings like this one:

'warning “next-i18next > react-i18next@9.0.9” has incorrect peer dependency “i18next@>= 14.0.1”.

In this case, our package.json specifies i18next@^13.1.3, but the next-i18next package.json specifies react-i18next@^9.0.4 (currently v9.0.9) which has a peer dependency of i18next@^14.0.1. I think that we’re going to constantly run into these incorrect peer dependency warnings unless we just specify next-i18next as a peer dependency (with the lowest compatible version number). Then users could install our package alongside the other peer dependencies when they want to use next-i18next.

We would still have to keep the dev dependencies up to date, but the warnings would not show up for our users and I think it communicates more effectively that these packages are to be installed with our package and we only need to install them in our package if we’re doing some sort of development (e.g. our e2e tests).

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:23 (23 by maintainers)

github_iconTop GitHub Comments

1reaction
isaachinmancommented, Feb 4, 2019

@kachkaev Yes, I think I agree with you. The only true peer deps here are next and react.

@capellini To answer your question, I want next-i18next to be a replace for both react-i18next and i18next. In general there is quite a lot of confusion and lack of knowledge in the dev community about i18next and its ecosystem, and this package attempts to hide a lot of that away and allow users to just think about their JSON namespaces and get on with it.

However, for advanced use cases, I believe that users may still need to use i18next

What cases? If there are situations where users need to install and import i18next directly, that probably means we’ve failed to expose some part of the API.

0reactions
capellinicommented, Feb 4, 2019

Understood. It makes much more sense now that I see the example implementation. Thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Understanding Peer Dependencies in JavaScript
When to use peerDependencies? ... Peer dependencies really come into play when you're developing code that will be used by others, such as...
Read more >
Why use peer dependencies in npm for plugins?
When should you use peer dependencies? · When you are building a library to be used by other projects, and · This library...
Read more >
Why use peer dependencies?
Peer dependencies are a useful pattern to avoid duplicated libraries ending up on the client, but it's likely not worth it for most...
Read more >
Peer Dependencies
Peer dependencies are pretty simple to use. When writing a plugin, figure out what version of the host package you peer-depend on, ...
Read more >
npm Peer Dependencies - JavaScript inDepth
Peer Dependencies are used to specify that our package is compatible with a specific version of an npm package. Good examples are Angular...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found