fluttercommunity / fluttercommunity/import_sorter
Guidelines / solution to run compiled version
- Dominant language
- Dart
- Stars
- 183
- Forks
- 42
- PR merge metrics
- No merged PRs in 30d
Description
**Is your feature request related to a problem? Please describe.**
The current execution of `flutter pub run import_sorter:main` has a slow start due to the Dart VM initialisation. While it is acceptable if it is ran infrequently (like as a GIT commit hook for example), it is a lot more critical when running frequently (like every time a file is saved for example).
**Describe the solution you'd like**
- Give users guidelines to use the natively compiled version of the library rather that its Dart version
- OR find a way to distribute the compiled versions
**Describe alternatives you've considered**
I have tested the execution time of this library for three different versions:
- 1: The Dart version, as described in the README
- 2: The AOT compiled version, as described in https://dart.dev/tools/dart-compile#aot-snapshot
- 3: The executable compiled version, as described in https://dart.dev/tools/dart-compile#exe
Results:
- 1 was the slowest, with an initialisation time of about 1 to 2 seconds on a i9 2019 Macbook Pro 16'.
- 2 was faster, maybe twice faster.
- 3 was the fastest, almost instantaneous
**Additional context**
The benefits of running a compiled version are also explained in https://dart.dev/tutorials/server/get-started#6-compile-for-production.
This is what I've done to get a nice experience using this lib:
1. Compile to native code
```shell
dart compile exe bin/main.dart -o bin/import_sorter
```
2. Add bin path to `PATH`
3. Use lib in VSCode with https://marketplace.visualstudio.com/items?itemName=emeraldwalk.RunOnSave
I've set it up with the following settings:
```json
"emeraldwalk.runonsave": {
"commands": [
{
"match": "\\.dart$",
"cmd": "import_sorter ${file}"
}
]
}
```
Now every time I save a file in my IDE, the imports are organised instantaneously! This makes it a lot more enjoyable.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the README instructions for running import_sorter and the entry point in bin/main.dart, then review the linked Dart AOT and executable compilation guidance. Done means users have a documented native-executable workflow, or the project has a clearly defined supported approach for distributing compiled versions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart
- Domain
- build-system, documentation
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100