minification issues #95
Description
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 like this.list
fails because this
is undefined
.
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:
class UserList {}
class UserController {
constructor(list) {
this.list = list
}
}
annotate(UserController, new Inject(UserList))
write this:
class UserList {}
class UserController {
constructor(list) {
this.list = list
}
}
// add a factory around a class :/
annotate(UserFactory, new Inject(UserList))
function UserFactory (list) {
return new UserController(list)
}
not ideal, but at least it gets the job done