merging_builder
1.1.2, released 2 weeks ago by simphotonics.com
Merges multiple input files into a single output file during the build process.
What it does
The package provides a builder that reads several source files and writes a single merged file. It supports optional topological sorting of inputs and custom output paths.
AI-written summary of version 1.1.2, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to combine generated code from multiple files into one file
- You want to control the order of merged assets
- You are already using build_runner and source_gen for code generation
Skip it when
- You only need to generate a single file
- You prefer a simpler, non‑stream based approach
Strengths
- Integrates with build_runner and source_gen
- Supports topological sorting to avoid dependency cycles
- Customizable input/output via build.yaml
- No runtime overhead – all work happens at build time
Weaknesses
- Only works with Dart build system
- Requires build_runner configuration
- Limited to merging – not suitable for other code generation patterns
Setup
- Kind
- Pure Dart
- Effort
- Medium
- Code generation
- Yes (build_runner)
- Direct dependencies
- 10
Add merging_builder to dependencies, configure build.yaml with build_extensions and options, run `dart run build_runner build`
```dart
// build.yaml
builders:
merging_builder:
import: "package:merging_builder/merging_builder.dart"
builder_factories: ["mergingBuilder"]
build_extensions: {"lib/$lib$": ["lib/merged.dart"]}
auto_apply: root_package
build_to: source
```Alternatives
Packages that do the same job and could replace merging_builder.
- code_builder
A fluent, builder-based library for generating valid Dart code programmatically.
93Compare - build_version
Generate a Dart file with the package version at build time.
77Compare - json_serializable
Automatically generate code for converting Dart classes to and from JSON.
94Compare - widgetbook_annotation
Annotations for widgetbook_generator to build Flutter widgets in isolation.
80Compare
Works with
Packages commonly used together with merging_builder: ones it builds on, ones built on it, and its own family.
- analyzermerging_builder depends on itPerforms static analysis of Dart code for tool integration and embedding.
- globmerging_builder depends on itA file and directory globbing library that supports Bash-style path matching and listing.
- dart_stylemerging_builder depends on itProvides an API and CLI to format Dart source code automatically.
- filemerging_builder depends on itPluggable, mockable file system abstraction for Dart with in-memory support.
- buildmerging_builder depends on itPackage for authoring build_runner compatible code generators.
- build_runnermerging_builder depends on itA build system for Dart code generation and modular compilation.
- source_genmerging_builder depends on itSource code generation builders and utilities for the Dart build system.
- directed_graphmerging_builder depends on itGeneric directed and weighted directed graph data structures with algorithms for sorting and paths.