ngUpgraders / ng-forward

The default solution for those that want to write Angular 2.x style code in Angular 1.x
411 stars 36 forks source link

General questions about ng-forward #115

Closed tolemac closed 8 years ago

tolemac commented 8 years ago

Hello all!

I have to start a new project. A week ago, I was thinking about the best way to prepare for Angular 2, I didn't know this project but I came to the same conclusion as you, I wrote this post in my blog: http://code.jros.org/2015/12/04/ng2emulation-typescript-angular-1-4-code-using-angular-2-style/ and I started this project: https://github.com/tolemac/Ng2Emulation

I'm publishing my post in some forums and somebody tell me about ng-forward: https://groups.google.com/forum/?hl=es#!topic/angular/-jFGjYTY754

Well, now I'm thinking about use ng-forward, I'm looking at the code and looking at like you do things.

I have some questions:

  1. Why you depends of reflect-metadata?, I think it isn't needed...
  2. I don't understand what is "bundle" concept, I have reading Angular 2 docs but I not found any reference to "bundle", is it needed? I think all module initializating have to do in bootstrap function.
  3. I don't understand "module.ts", "opaque-token.ts" and "provider.ts" ...

I would like to know how you organize the project, due to, at firts glance, I can see too much code ...

In other words, I think that this kind of project should be a very slim layer between user code and framework code (Angular 1).

Perhaps my questions are too general and you don't have time to answer me, if it is, I have any problem ;)

Thanks in advance.

tolemac commented 8 years ago

In the other hand, I would like to know how to build the project to try contribute.

Can you tell me the necessary steps to build?

timkindberg commented 8 years ago

@tolemac Hi Javier, thanks for your interest in contributing and your critical comments.

We started this project from another project (angular-decorators by @MikeRyan52) so there was some existing classes there that we kept (e.g. Module) and just used them as they were convenient even though we probably wouldn't do it that way if we would have started from scratch.

Per your questions specifically:

  1. We depend on reflect-metadata for our MetaStore class. Could have not done it that way? Yes. But reflect is in the spec and is the proper way to attach metadata to a class. So we went in that direction with the small inconvenience of having a dependency on 'reflect-metadata'. Perhaps we could just add that file into our bundle automatically.
  2. 'bundle' is not an Angular 2 api, but it is helpful when you would like to migrate an Angular 1 codebase over to ng-forward. It's basically bootstrapping without the actual call to angular.bootstrap. So it takes an entry point Component, traces its dependencies (i.e. directives, providers, pipes) and bundles them up into a single angular.module which you can then use as a dependency in a normal ng1 codebase. It's really not intended to be used most of the time. We call it for you when you call bootstrap.
  3. module.ts is just a wrapper around angular.module that sugars it a bit for our internal development. Makes it just a bit easier to add decorated classes to a module.
  4. opaque-token is something I took straight out of Angular 2, so we also thought that one was weird, but it is a pure polyfill. There are some docs in the API.md file on it.
  5. provider.ts is also another 1-to-1 polyfill of an Angular 2 feature.

We are aiming to be the most complete Angular 2 polyfill. Not just a simple @Component polyfill.

To contribute, clone the repo, run npm i, run gulp to build or gulp dev to run tests in watch mode.

tolemac commented 8 years ago

Thank you very much @timkindberg. It help me to understand a lot of things.