pbastowski / angular2-now

Angular 2 @Component syntax for Angular 1 apps
MIT License
145 stars 15 forks source link

Update build process to use babel6 #52

Closed kamilkisiela closed 8 years ago

kamilkisiela commented 8 years ago

We're using babel5 at the moment which is out of date.

There are no changes in tests and source but coverage decreased. It seems like new version of isparta-loader have different rules or changed methodology.

@pbastowski what do you think?

pbastowski commented 8 years ago

@kamilkisiela I think it's a good idea to update to Babel 6. I also have an interesting way to use TypeScript to do this, which I want to show you at some stage.

The change in coverage is strange, but, at the same time it's only a small decrease. If you're ok with it then so am I.

So, go ahead and merge :)

pbastowski commented 8 years ago

@kamilkisiela I recently read about how Babel 6 sometimes produces different code to Babel 5, for instance when transpiling ES7 decorators. Since you upgraded to Babel 6, the coverage dropped slightly, which could be due to the differences in the compiled code. I haven't done any testing to prove this hypothesis, but I dreamed about it the other night :) and thought it's better written down here than appearing in my dreams.

kamilkisiela commented 8 years ago

@pbastowski Correct me if I'm wrong.

In angular2now's source code we define decorator's body with target, key and descriptor as the arguments (in the same order) so it's compatible with babel5's transpiling plugin for decorators and with babel-plugin-transform-decorators-legacy for babel6 use.

In tests we use angular2now.Component(options)(target) which means that there is no decorators transpiling at all.

Babel6 with preset (babel-preset-es2015) that we use in testing and build process is compatible with es2015. So the only things that are transpiled are from ratified standard. What I mean by that? Classess, arrow functions, shorthand decraration for objects etc.

As far I know, Istanbul converts source code into new code with "wrapper functions" so every exectuion of them could be counted. As I said before we're not using @Decorator in tests so Isparta (Istanbul instrumenter for es6) sees that as normal functions.


It's late and I'm after 11 hours of working so I'm not sure if I'm not dreaming right now too :smiley:

Maybe you saw an horror before sleep and then the natural reaction was to dream about code transpiling by babel which is the only thing in angular2now we do not have direct controll! :scream:


I will do some testing tomorrow's evening :)

kamilkisiela commented 8 years ago

@pbastowski Or I misunderstood you and the only good thing of that essay I wrote is that it is always good to practice my english skills? :)

pbastowski commented 8 years ago

Well, if you're not using ES7 decorators in any tests then there should be no difference in the generated code due to that. It was just a scary thought of mine. BTW, it's a nice essay and +1 for the English too!

kamilkisiela commented 8 years ago

@pbastowski you're very kind :) I made few mistakes including english istead of English :)

So should I test it tomorrow or leave it as it is?

pbastowski commented 8 years ago

Leave it as is, Kamil.