cincheo / jsweet-angular2-quickstart

JSweet-enabled Angular 2 quickstart
MIT License
9 stars 8 forks source link

Module names #1

Closed kito99 closed 7 years ago

kito99 commented 8 years ago

Right now it looks like the default name for the module files is always "module.ts". Can we customize this? I suppose I'm expecting the output to look like a standard Angular2 app, but maybe that's not necessary. It would help, however, when naming templates and other dependencies to know exactly where they should go...

renaudpawlak commented 8 years ago

Yes... I have been thinking about it. It is not that simple and so far JSweet does not support it. So far JSweet considers that each package is a module. Typically, an approach I was thinking about is to annotate each class to belong to a module. For instance:

@ModuleTarget("test.component")
@Component(
  templateUrl: 'test.component.html',
)
public class MyComponent { ... }

This approach would require to annotate all classes with a @ModuleTarget annotation and I don't think that it would be that convenient... In any case, the problem with Java being that the name of the file must follow the name of the public class... that restricts a lot what you can do with your source code (w.r.t. modules). Of course, it would be better if your generated code looked exactly like hand-written modules, but we also have to keep in mind that it is generated code :)

Another approach would be keep the rule one package = one module, but to use a package-level annotation to give the path of the target module. It would probably be easier for the programmers.

renaudpawlak commented 8 years ago

@kito99 Do you need module.id? https://github.com/johnpapa/angular2-tour-of-heroes/blob/master/app/dashboard.component.ts#L8

I have opened #2 if you want to react on it.

renaudpawlak commented 7 years ago

Fixed in JSweet 2.