Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use generator instead of transformer #9

Open
Aetet opened this issue Aug 25, 2017 · 7 comments
Open

Use generator instead of transformer #9

Aetet opened this issue Aug 25, 2017 · 7 comments

Comments

@Aetet
Copy link

Aetet commented Aug 25, 2017

As I know dart team will deprecate transformer API favor to builder api. Like https://github.com/google/built_value.dart I think it would be great if it ll be builder from the beginning

@hourliert
Copy link
Member

Thanks for your comment. I have never wrote a transformer but I am eager to learn.

Do you mean that this is the Builder API: https://github.com/dart-lang/build ?

@Aetet
Copy link
Author

Aetet commented Aug 26, 2017

Yep. This is it. Example of the generator:
https://github.com/google/built_value.dart/tree/master/built_value_generator

Generator must be separate package. This prevent problems from analyzer, source_gen deps. Because they always must be sync with upstream.

@hourliert
Copy link
Member

Thanks a lot for your issue. I will have a look at this during the week 👍 .

@hourliert
Copy link
Member

hourliert commented Aug 31, 2017

Hi @Aetet,

I am looking at Generators right now and I have some questions.

  • AngularDart seems to use (not everywhere) "old transformers", do you think they will migrate to generators?
  • Why should I create a separate package for the generator? The angular codegen transformer seems to be included into the main repo : https://github.com/dart-lang/angular/blob/master/angular/lib/transform/codegen.dart
  • Is there any best practice to name a generator repository that is related to a library?
  • I have seen that graphql_client users will have to launch a "watcher" (as detailed here). Is there a way to launch this command in parallel of launching pub serve?

Thanks in advance!

EDIT: Ready almost ready! https://github.com/hourliert/graphql_client/tree/master/graphql_client_generator 😂

@Aetet
Copy link
Author

Aetet commented Sep 1, 2017

Hi, @hourliert

  1. AFAIK they want to migrate to new compiler Remove PLATFORM_* (directives|pipes) from AngularDart angulardart/angular#363 but also supports transformers for backward compatibility

  2. The main issue - all modules even for dev dependency must satisfy by version. For example you have following deps:

dep:
  built_value: 
  angular: 4.0.0
dev_dep:
   # for coverage
  dart_dev: 1.0.0

And if your package for coverage dart_dev wants analyzer 0.28.0 and angular 0.30.0 - because of semver we cannot resolve this deps.

So you need downgrade angular, or patch dart_dev by yourself, or separate dart_dev as external package. And run it like cli.

Occasionally will run into this problem. For built_value_generator, dartfmt, less_transformer, etc. That's why you need to reduce it with separate package. To solve this problem by infrastructure we need separate section at pubspec for this deps. But AFAIK it won't be shipped at Dart 2.0.

  1. Usually generator named like library but with suffix 'generator' like: built_value - built_value_generator
  2. As I can see at the issues Support an alternative build/serve mechanism to Barback angulardart/angular#420 they want to deprecate pub serve too. I think dart developers at https://gitter.im/dart-lang/angular2 can answer your questions more precisely.

I think good practice to use single repo for generator and library, but have separate package for them at pub.

Thanks to you!

@hourliert
Copy link
Member

Awesome, thanks a lot for your answer.
I'll keep this issue updated.

@g33kidd
Copy link

g33kidd commented Mar 22, 2018

@hourliert Has there been any progress on this front? This would indeed be a handy feature! I'd love to help out where I can.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants