dart-lang / dart-lang/language
Allow imports in part files
- Dominant language
- TeX
- Stars
- 2.9k
- Forks
- 239
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 14
Description
Currently, when generating code, the `part` file can't have specific imports and they need to be added in the hand written file.
This behavior restricts the ergonomics of code generation in:
1) Clients of code generating libraries need to update their hand written files with imports.
2) The hand written files have references to imports that are not used in that file.
Use case:
A library split in two artifacts.
- Annotation library which is declared only as `dependencies`
- Code generating library which is declared only as `dev_dependencies`
The code generating library that need to check the `Platform`, something like `Platform.isAndroid` in the generated code.
This means :
The library client developer will need to add `import 'dart:io';` to the hand written code to make the project compile as this is the import that contains the `Platform` class.
As I understand this need to declare by the imports "by hand" is meant to avoid a missing dependency in the project, but this could be avoid if the annotation library declares if it declares the package dependency.
The concrete example of the problem can be found [here](https://github.com/BugsBunnyBR/plugin_gen.flutter/blob/master/example/lib/my_platform_plugin.dart#L1).
Contributor guide
Research direction
Start by reading the issue and the concrete example in example/lib/my_platform_plugin.dart linked from the report. Examine how the annotation and code-generating libraries are separated, then clarify the language and dependency implications of allowing imports in part files. Done means the proposed behavior and its dependency rules are resolved in the Dart language design.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100