Creating an external closure compiler

I am using jQuery plugin and Google Closure compiler. The problem is that an error appears in the plug-in, when I add the URL of this plug-in to compilation, compilation fails. So I want to create extern for this plugin. Basically, I use only 1 object and 2 methods from the entire library; something like that:

var TheObject = $.plugin({...}); var SomeVar = TheObject.someName.otherName(SomeString, { prop1: [...], onError: function () {...} }); TheObject.SomeMethod(); 

I looked at the document on the Google website, but it wrote from a confusing point of view β€œwhat is it,” and I need a simple β€œpractical” perspective on how to do this. What do I need to do to create extern for what I have?

Thanks.

+7
javascript google-closure-compiler
source share
2 answers

Thus, I struggled with this issue for a while, and I got a working solution for others who have a plug-in that they want to use in their code with the closure compiler: instead of doing extern, just use the lines, for example:

 var TheObject = $['plugin']({...}); var SomeVar = TheObject['someName']['otherName'](SomeString, { 'prop1': [...], 'onError': function () {...} }); TheObject['SomeMethod'](); 

It may not work for everyone, but it worked for me and saved me the hassle of writing extern. I found the document on the Internet very confusing: either written by technical experts who explain what it is, but now, how to use them or write in a professorial tone, there are not many empirical examples. Hope this answer helps others.

+2
source share

Here you go:

I did not have time to complete the externs series. If this is not enough for your project, I will move on to the topic.

+10
source share

All Articles