0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【Flutter】pubspec.yaml の dependencies と dev_dependencies の違い

Posted at

dependencies と dev_dependencies の違い

結論から書くと、
アプリを動かすのに必要なパッケージは dependencies
リンターだったりテスト用だったり開発時にのみ必要なパッケージは dev_dependencies
に書けば良さそう。

アプリの実行速度にも影響するそうなので、
開発時のみにしか使用しないパッケージは積極的に dev_dependencies を使った方が良さそう。

参照したところ

公式 (https://dart.dev/tools/pub/pubspec#dependencies) に、

Dependencies
Dependencies are the pubspec’s raison d’être. In this section you list each package that your package needs in order to work.

Dependencies fall into one of two types. Regular dependencies are listed under dependencies:—these are packages that anyone using your package will also need. Dependencies that are only needed in the development phase of the package itself are listed under dev_dependencies.

とある。

DeepLで訳すと

ディペンデンシー(依存関係
依存関係はpubspecの存在意義です。このセクションでは、あなたのパッケージが動作するために必要とする各パッケージをリストアップします。

依存関係は2つのタイプに分類されます。通常の依存関係は、dependencies:の下にリストアップされています。パッケージの開発段階でのみ必要とされる依存関係は、dev_dependencies に記載されています。

となる。

こちら(https://dart.dev/tools/pub/dependencies#dev-dependencies) にも

The rule for deciding between a regular or dev dependency is simple: If the dependency is imported from something in your lib or bin directories, it needs to be a regular dependency. If it’s only imported from test, example, etc. it can and should be a dev dependency.

Using dev dependencies makes dependency graphs smaller. That makes pub run faster, and makes it easier to find a set of package versions that satisfies all constraints.

通常の依存関係かdev依存関係かを決定するルールは簡単です: 依存関係が lib または bin ディレクトリの何かからインポートされる場合、それは通常の依存関係である必要があります。もし、testやexampleなどからしかインポートされないのであれば、dev依存にすることができますし、そうすべきです。

dev依存関係を使用すると、依存関係のグラフが小さくなります。そのため、Pubの実行が速くなり、すべての制約を満たすパッケージバージョンのセットを見つけることが容易になります。

とある。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?