External dependency and minification

For developers using the Construct 2 Javascript SDK

Post » Mon Feb 01, 2016 12:01 pm

Hi stumbled upon an interesting issue that I know how to fix with a simple hack, but I would love to know the proper way.

My plugin has a dependency set as:

Code: Select all
"dependency":           "leaderbird.min.js"


Which returns an object:
Code: Select all
leaderbird = function() {}();


Obviously my plugin references said object across the various actions, expressions and conditions.
When the minification process happens, another string gets appended to the variable such as leaderbird0b, which of course doesn't exist.

Is there any way to "protect" a specific variable? Or is this a case of having to manually rename the value?

Thanks
B
30
S
9
G
6
Posts: 525
Reputation: 8,329

Post » Mon Feb 01, 2016 12:17 pm

Yes, the minification guide already covers this. You need to use obj["prop"] syntax.
Scirra Founder
B
399
S
236
G
89
Posts: 24,521
Reputation: 195,365

Post » Mon Feb 01, 2016 11:57 pm

Horribly sorry @Ashley, but I cannot seem to find this entry in the manual, do you have a link? It might be useful to leave it here in case someone stumbles upon this one.
B
30
S
9
G
6
Posts: 525
Reputation: 8,329

Post » Tue Feb 02, 2016 12:16 am

B
94
S
33
G
113
Posts: 5,356
Reputation: 73,273

Post » Tue Feb 02, 2016 8:38 am

0plus1 wrote:Horribly sorry @Ashley, but I cannot seem to find this entry in the manual, do you have a link? It might be useful to leave it here in case someone stumbles upon this one.


I don't think it needs to be repeated here as it is adequately covered under the heading 'Google Closure Compiler compatibility'.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
136
S
31
G
86
Posts: 5,486
Reputation: 59,758


Return to Javascript SDK

Who is online

Users browsing this forum: No registered users and 1 guest