Skip to content

Tree Shaking Issue with Converter Registration #10

Open
@shtse8

Description

@shtse8

Hi,

First of all, thank you for this great project!

I have a question regarding the tree shaking capabilities in Dart when using your library. In the initialiseDogs method, all converters are registered as follows:

Future initialiseDogs() async {
  var engine = DogEngine.hasValidInstance ? DogEngine.instance : DogEngine();
  engine.registerAllConverters([gen0.UserConverter()]);
  engine.setSingleton();
}

My understanding is that by registering all converters this way, the Dart optimizer might be unable to tree shake unused dataclasses. Since the converters require the dataclass as a generic parameter, it seems that the dataclass itself will be included in the final build, even if it is unused. This could potentially increase the bundle size.

Could you please clarify if my understanding is correct? Is there any way to ensure that only the used dataclasses and their respective converters are included in the final build, allowing the optimizer to effectively tree shake the unused ones?

Thank you in advance for your response!

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions