jam compile error with amplifyjs

99 views
Skip to first unread message

Hyojung Kwon

unread,
Oct 22, 2012, 6:04:07 AM10/22/12
to ja...@googlegroups.com
Hello, 
I am looking at jam to use next project, it is fantastic and exactly what I was looking for.

My problem is that I have error when I tried to use amplify in my app.

I firstly install amplifyjs in my app and I used it without any problem, but after I 'jam compile' all my javascript app into one file then I got undefined error.

following is my initial app.js file code :

require(['jquery', 'amplify'],
    function($, amplify){
        console.log('jquery=' + $);
        console.log('amplify=' + amplify);
    }
);

Error is that amplify is undefined.

So I looked inside of app.min.js file (optimized file) and I notice that compile command generated following snippet :

define('amplify', ['amplify/amplify'], function (main) {  return main; });
define("amplify/amplify", function(){ });

Above code is located right after original amplify.js code section.

Looking at that code you may recognize that 'amplify' module does not return anything so that I could not get amplify instance in my app.js code

I also notice that amplify.js is using shim configuration.

I am wondering that I need additional option to compile it correctly.
Or, Is this bug of jam compile command?

Please give me advice or hint.
Thanks in advance.



Kadir Doğan

unread,
Oct 23, 2012, 3:44:30 PM10/23/12
to ja...@googlegroups.com
Hello Hyojung, 

sory for my late response. I saw your mention just now. I noticed same error when compiling my js. Problem is amplifyJS is not amdify library so i wrap amplify js codes with amd pattern. 

(function(root, doc, factory) {

if (typeof define === "function" && define.amd) {

// AMD. Register as an anonymous module.

define(["jquery"], function($) {

return factory($, root, doc);

});

} else {

// Browser globals

factory(root.jQuery, root, doc);

}

}(this, document, function($, global, document, undefined) {

... amplify codes ...


}( amplify, jQuery ) );

return amplify;

}));

I hope my humble solution works for you. 

22 Ekim 2012 Pazartesi 13:04:07 UTC+3 tarihinde Hyojung Kwon yazdı:

Hyojung Kwon

unread,
Oct 23, 2012, 6:29:12 PM10/23/12
to ja...@googlegroups.com
Thanks Kadir

That's exactly the same I resolved issue.
BTW, your saying "Problem is amplifyJS is not amdify library" means that library used shim configuration would have trouble after compiling ?

Regards,
Hyojung

2012/10/24 Kadir Doğan <kadir....@gmail.com>

--
You received this message because you are subscribed to the Google Groups "jamjs" group.
To post to this group, send an email to ja...@googlegroups.com.
To unsubscribe from this group, send email to jamjs+un...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msg/jamjs/-/6SD4reRR6BkJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Hyojung Kwon
(Cell) 82-10-2676-1072


Kadir Doğan

unread,
Oct 23, 2012, 6:50:06 PM10/23/12
to ja...@googlegroups.com
No I mean amplify library does not use amd patterns. https://github.com/appendto/amplify/issues/43 .

24 Ekim 2012 Çarşamba 01:29:13 UTC+3 tarihinde Hyojung Kwon yazdı:
Reply all
Reply to author
Forward
0 new messages