Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Pub workspaces로 monorepo 구성하기 @2025_Flutter in ...

Pub workspaces로 monorepo 구성하기 @2025_Flutter in Production 박제창

Flutter In Production Extended Seoul
Pub workspaces로 monorepo 구성하기
https://event-us.kr/flutterseoul/event/96401

JaiChangPark

January 11, 2025
Tweet

More Decks by JaiChangPark

Other Decks in Programming

Transcript

  1. 3

  2. 4

  3. 5

  4. 6

  5. “ Pub now supports shared resolution between packages in a

    monorepo, or workspace. A workspace is a tightly related group of packages developed, resolved, and released together. — Announcing Dart 3.6 7
  6. 9

  7. In version-control systems, a monorepo ("mono" meaning 'single' and "repo"

    being short for 'repository') is a software-development strategy in which the code for a number of projects is stored in the same repository. This practice dates back to at least the early 2000s, when it was commonly called a shared codebase. Google, Meta, Microsoft, Uber, Airbnb, and X all employ very large monorepos with varying strategies to scale build systems and version control software with a large volume of code and daily changes. a software-development strategy Monorepo 10 @source: https://en.wikipedia.org/wiki/Monorepo
  8. Monorepo : Advantages dependency management In a multiple repository environment

    where multiple projects depend on a third-party dependency, that dependency might be downloaded or built multiple times. In a monorepo the build can be easily optimized, as referenced dependencies all exist in the same codebase. code reuse Similar functionality or communication protocols can be abstracted into shared libraries and directly included by projects, without the need of a dependency package manager. Collaboration across teams In a monorepo that uses source dependencies (dependencies that are compiled from source), teams can improve projects being worked on by other teams. This leads to flexible code ownership. 11 @source: https://en.wikipedia.org/wiki/Monorepo
  9. Monorepo : disadvantages More storage needed by default With split

    repositories, you fetch only the project you are interested in by default. With a monorepo, you check out all projects by default. This can take up a significant amount of storage space. While some versioning systems have a mechanism to do a partial checkout, doing so defeats some of the advantages of a monorepo. Loss of version information Although not required, some monorepo builds use one version number across all projects in the repository. This leads to a loss of per-project semantic versioning. 12 @source: https://en.wikipedia.org/wiki/Monorepo
  10. 전환 또는 도입은 언제나 (옵션)선택사항 • 앱이 점점 슈퍼 앱이

    되어가고 있다면 • 협업하는 팀원이 늘어나고 있다면 • 커스텀이 필요한 네이티브 패키지 개발이 필요하다면 • 커스텀 패키지의 소스 오픈이 제한되어 있다면 • n개의 앱(하나이상의 앱)이 동일한 로직(ex:도메인 또는 데이터 모델)을 사용하고 있다면 언제 도입하는게 적절할까요? Monorepo 13
  11. Monorepo 16 Melos • Automatic versioning & changelog generation. •

    Automated publishing of packages to pub.dev. • Local package linking and installation. • Executing simultaneous commands across packages. • Listing of local packages & their dependencies.
  12. The pub workspaces feature ensures that packages in a monorepo

    share a consistent set of dependencies. This forces you to resolve dependency conflicts between your grouped packages as they arise, rather than facing confusion when you start using the packages. The Flutter analyzer processes all of the packages in a pub workspace in a single analysis context, as opposed to the previous behavior of a separate context for each package. For large repositories, this can significantly reduce the amount of memory the Dart language server consumes, improving IDE performance. monorepo support Pub workspaces 19 @source: https://medium.com/dartlang/announcing-dart-3-6-778dd7a80983
  13. 20

  14. 23 📦my_app ┣ 📂lib ┃ ┗ 📜main.dart ┣ 📜.gitignore ┣

    📜.metadata ┣ 📜README.md ┣ 📜analysis_options.yaml ┣ 📜my_app.iml ┣ 📜pubspec.lock ┗ 📜pubspec.yaml
  15. 27 @source: https://docs.flutter.dev/app-architecture/concepts https://docs.flutter.dev/app-architecture/case-study lib |____ui | |____core | |

    |____ui | | | |____<shared widgets> | | |____themes | |____<FEATURE NAME> | | |____view_model | | | |_____<view_model class>.dart | | |____widgets | | | |____<feature name>_screen.dart | | | |____<other widgets> |____domain | |____models | | |____<model name>.dart |____data | |____repositories | | |____<repository class>.dart | |____services | | |____<service class>.dart | |____model | | |____<api model class>.dart |____config |____utils |____routing |____main_staging.dart |____main_development.dart |____main.dart
  16. 30 📦lib ┣ 📂domain ┃ ┗ 📂models ┃ ┃ ┣

    📂hacker_news ┃ ┃ ┃ ┣ 📜hn.dart ┃ ┃ ┃ ┣ 📜hn.freezed.dart ┃ ┃ ┃ ┗ 📜hn.g.dart ┃ ┃ ┗ 📂user ┃ ┃ ┃ ┣ 📜user.dart ┃ ┃ ┃ ┣ 📜user.freezed.dart ┃ ┃ ┃ ┗ 📜user.g.dart
  17. 31 📦lib ┣ 📂data ┃ ┣ 📂providers ┃ ┃ ┣

    📜dio_provider.dart ┃ ┃ ┗ 📜dio_provider.g.dart ┃ ┣ 📂repositories ┃ ┃ ┣ 📜hn_repository.dart ┃ ┃ ┣ 📜hn_repository.g.dart ┃ ┃ ┣ 📜user_repository.dart ┃ ┃ ┗ 📜user_repository.g.dart ┃ ┗ 📂services ┃ ┃ ┣ 📜hacker_news_api.dart ┃ ┃ ┣ 📜hacker_news_api.g.dart ┃ ┃ ┣ 📜user_api.dart ┃ ┃ ┗ 📜user_api.g.dart
  18. 32 📦lib ┣ 📂data ┃ ┣ 📂providers ┃ ┃ ┣

    📜dio_provider.dart ┃ ┃ ┗ 📜dio_provider.g.dart ┃ ┣ 📂repositories ┃ ┃ ┣ 📜hn_repository.dart ┃ ┃ ┣ 📜hn_repository.g.dart ┃ ┃ ┣ 📜user_repository.dart ┃ ┃ ┗ 📜user_repository.g.dart ┃ ┗ 📂services ┃ ┃ ┣ 📜hacker_news_api.dart ┃ ┃ ┣ 📜hacker_news_api.g.dart ┃ ┃ ┣ 📜user_api.dart ┃ ┃ ┗ 📜user_api.g.dart
  19. 33 📦lib ┣ 📂ui ┃ ┣ 📂core ┃ ┃ ┣

    📂shared ┃ ┃ ┗ 📜theme.dart ┃ ┣ 📂hacker_news ← Feature 1 ┃ ┃ ┣ 📂view_model ┃ ┃ ┃ ┣ 📜hacker_news_view_model.dart ┃ ┃ ┃ ┗ 📜hacker_news_view_model.g.dart ┃ ┃ ┗ 📂widgets ┃ ┃ ┃ ┣ 📜hacker_news_screen.dart ┃ ┃ ┃ ┗ 📜news_list_widget.dart ┃ ┣ 📂user ← Feature 2 ┃ ┃ ┣ 📂view_model ┃ ┃ ┃ ┣ 📜user_view_model.dart ┃ ┃ ┃ ┗ 📜user_view_model.g.dart ┃ ┃ ┗ 📂widgets ┃ ┃ ┃ ┣ 📜user_list_widget.dart ┃ ┃ ┃ ┗ 📜user_screen.dart
  20. 34 📦lib ┣ 📂ui ┃ ┣ 📂core ┃ ┃ ┣

    📂shared ┃ ┃ ┗ 📜theme.dart ┃ ┣ 📂hacker_news ← Feature 1 ┃ ┃ ┣ 📂view_model ┃ ┃ ┃ ┣ 📜hacker_news_view_model.dart ┃ ┃ ┃ ┗ 📜hacker_news_view_model.g.dart ┃ ┃ ┗ 📂widgets ┃ ┃ ┃ ┣ 📜hacker_news_screen.dart ┃ ┃ ┃ ┗ 📜news_list_widget.dart ┃ ┣ 📂user ← Feature 2 ┃ ┃ ┣ 📂view_model ┃ ┃ ┃ ┣ 📜user_view_model.dart ┃ ┃ ┃ ┗ 📜user_view_model.g.dart ┃ ┃ ┗ 📂widgets ┃ ┃ ┃ ┣ 📜user_list_widget.dart ┃ ┃ ┃ ┗ 📜user_screen.dart
  21. 46