I have simple class (with Dojo):
define ["dojo/request", "dojo/html", "dojo/on", "dojo/dom"], (request, html, observe, dom) ->
class Foo
constructor: (@a) ->
alert @a
I create a new object of this class at different file:
require ["Libraries/Foo", "dojo/domReady!"], (Foo) ->
t = new Foo "test"
When I compile the Foo class file into JS, everything works without problem, but when I minify the JS output with for example http://jscompress.com code will broke up.
After minification code looks like:
// Generated by CoffeeScript 1.4.0
(function(){define(["dojo/request","dojo/html","dojo/on","dojo/dom"],function(e,t,n,r){var i;return i=function(){function e(e){this.a=e;alert(this.a)}return e}()})}).call(this);
At console (Safari, Chrome) I can see:
TypeError: '[object Object]' is not a constructor (evaluating 'new Foo("test")')
But when I reformat code using tool at my IDE, everything works OK.
Code after reformation:
// Generated by CoffeeScript 1.4.0
(function () {
define(["dojo/request", "dojo/html", "dojo/on", "dojo/dom"], function (e, t, n, r) {
var i;
return i = function () {
function e(e) {
this.a = e;
alert(this.a)
}
return e
}()
})
}).call(this);
Where can be problem please?
Problem solved! Using
async: truein Dojo config.