Skip to content

Commit e6ace7e

Browse files
atsansoneparlough
andauthored
Added info on dependency version constraints (#5431)
Fixes #4811 --------- Co-authored-by: Parker Lougheed <parlough@gmail.com>
1 parent 9a850bf commit e6ace7e

File tree

1 file changed

+29
-8
lines changed

1 file changed

+29
-8
lines changed

src/content/tools/pub/dependencies.md

+29-8
Original file line numberDiff line numberDiff line change
@@ -418,14 +418,13 @@ are ignored by all users of your package.
418418

419419
## Best practices
420420

421-
It's important to actively manage your dependencies and
422-
ensure that your packages use the freshest versions possible.
423-
If any dependency is stale,
424-
then you might have not only a stale version of that package,
425-
but also stale versions of other packages in your dependency graph that
426-
depend on that package.
427-
These stale versions can have a negative impact on
428-
the stability, performance, and quality of apps.
421+
Be proactive in managing your dependencies.
422+
Ensure that your packages depend on the freshest versions of packages
423+
when possible.
424+
If your package depends on a stale package,
425+
that stale package may depend on other stale packages in its dependency tree.
426+
Stale versions of packages can have a negative impact on
427+
the stability, performance, and quality of your app.
429428

430429
We recommend the following best practices for package dependencies.
431430

@@ -444,6 +443,28 @@ To identify dependencies in your app or package that
444443
aren't on the latest stable versions,
445444
use [`dart pub outdated`][].
446445

446+
### Tighten version constraints for dev dependencies
447+
448+
A dev dependency defines a package that you need only when developing.
449+
A finished app won't need these packages.
450+
Examples of these packages include tests or code generation tooling.
451+
Set the version constraints of packages in [`dev_dependencies`][dev-dep]
452+
to have a lower bound of the latest version on which your package depends.
453+
454+
Tightening the version constraints of your dev dependencies might
455+
resemble the following:
456+
457+
```yaml
458+
dev_dependencies:
459+
build_runner: ^2.4.8
460+
lints: ^2.1.1
461+
test: ^1.25.1
462+
```
463+
464+
This YAML sets the `dev_dependencies` to the latest patch versions.
465+
466+
[dev-dep]: /tools/pub/dependencies#dev-dependencies
467+
447468
### Test whenever you update package dependencies
448469

449470
If you run [`dart pub upgrade`][] without updating your pubspec,

0 commit comments

Comments
 (0)