-
Notifications
You must be signed in to change notification settings - Fork 95
minification issues #95
Comments
@markuz-brasil How do you know this is not getting fixed with #93 |
I took a look at the code, copied and pasted. I found out that uglifyy doesn't support Function.name link I think that there is no way to distinguish a class from a function in ES5 I feel like the solution is with annotations. Maybe a On Thursday, January 1, 2015, Tushar Mathur [email protected]
|
No, in ES6 they are deserialized as a class declaration or class expression ( |
Cool. Good to know. Thanks On Thursday, January 1, 2015, Caitlin Potter [email protected]
|
@markuz-brasil Actually #93 is a workaround so that the class doesn't throw up errors. class UserController {
constructor(list) {
this.list = list
}
//Add a method to the prototype chain
getFriends(){
//In most cases you will always have a method.
}
} It should work. |
Indeed, here is an example project: https://github.com/iammerrick/webpack-jsx-uglify-bug |
There is no way to distinguish a class from a function, di.js uses the function/class name - if it starts with an uppercase letter, it's treated as a class. Sounds like the minifier changes class names into lowercase letters. We can't treat everything as a class (call it with We can add additional annotation such as Any other ideas? |
I think the additional annotation is our best option. |
I also agree. Maybe something like @constructor as a hint for using ClassProvider and On Wednesday, January 7, 2015, Merrick Christensen [email protected]
|
Its just getting too verbose. Why can't we follow a convention as opposed to configuration? Like any function with a name can be considered as a class otherwise its a factory. |
This is also a problem with @InjectLazy. |
Is there a drawback of using the annotation approach? |
Addressing this with annotations here: https://github.com/angular/di.js/pull/96/files |
First of all, I'm using 6to5 instead of traceur and mocha/chai/sinon instead of karma/jasmine. (and yeah, I ported the tests)
Flame war apart, the tests shouldn't fail. Which doesn't, unless it is minified. (And I didn't bother trying with minified traceur output...)
I pinpointed the issue to the class' context being somehow set to
undefined
in the minified form. So things likethis.list
fails becausethis
isundefined
.Here is my project's git (minified) and all passing tests
I'm not clear where the issue actually is. I'm 99% certain that it isn't the testing framework. #93 doesn't fix it either. I'm left with this babel/babel#343, a bug on uglify or on the di framework itself. (or some combination of them)
My work around is something like this:
instead of writing this:
write this:
not ideal, but at least it gets the job done
The text was updated successfully, but these errors were encountered: