XF 2.3 Building JavaScript giving me issues once again...

Jaxel

Well-known member
Code:
$ php cmd.php xf-addon:build-release EWR/Discord
Performing add-on export.

Exporting data for [8WR] Discord Integration to /src/addons/EWR/Discord/_data.
 27/27 [============================] 100%
Written successfully.
Attempting to validate addon.json file...
JSON file validates successfully!

Building release ZIP.
Unexpected error while minifying JS: Empty result provided by the compiler.

Trying to build a release gives me this error. I only have 1 JavaScript file: discord.js:
Code:
var EWRdiscord = window.EWRdiscord || {};

((window, document) =>
{
    // ################################## --- ###########################################
    
    EWRdiscord.Botcheck = XF.Element.newHandler(
    {
        init: function()
        {
            XF.on(this.target, 'click', this.click.bind(this));
        },
        
        click (e)
        {
            const testButton = this.target;
            const token = testButton.dataset.token;
            
            var sequence = 0;
            var socket = new WebSocket("wss://gateway.discord.gg/?encoding=json&v=6");
            
            socket.onopen = function() { console.log("Discord: Websocket OPEN"); },
            socket.onerror = function(err) { console.error(err); },
            socket.onclose = function(err) { console.error(err); },
            socket.onmessage = function(msg)
            {
                try
                {
                    var data = JSON.parse(msg.data);
                    sequence = data.s;
                    
                    if (data.op == "10")
                    {
                        testButton.classList.add('button--cta');
                        testButton.querySelector('.button-text').textContent = "CONNECTED";
                        console.log('Discord: Sending handshake');
                        
                        socket.send(JSON.stringify({
                            op: 2,
                            d:
                            {
                                token: token,
                                properties:
                                {
                                    $browser: "DiscordBot (8wayrunBot, v2)"
                                },
                                large_threshold: 50
                            }
                        })),
                        setInterval(function()
                        {
                            testButton.querySelector('.button-text').textContent = "HEARTBEAT";
                            console.log('Discord: Sending heartbeat ('+sequence+')');
                            
                            socket.send(JSON.stringify(
                            {
                                op: 1,
                                d: sequence
                            }));
                        }, data.d.heartbeat_interval);
                    }
                }
                catch (err)
                {
                    testButton.classList.remove('button--cta');
                    testButton.querySelector('.button-text').textContent = "ERROR";
                    console.error(err);
                }
            };
        },
    });
    
    // ################################## --- ###########################################

    XF.Element.register('discord-botcheck', 'EWRdiscord.Botcheck');
}
)(window, document)

What would be causing this issue?
 
This is likely because the closure compiler web service is no longer available.


You will likely need to download the closure compiler binary, place it somewhere on your system and add the following to your src/config.php:

PHP:
$config['development']['closureCompilerPath'] = '/path/to/clousre/compiler';
 
So building addons can't compile minified JS automatically anymore? Will a replacement for the compiler be coming?
 
It's automatic, there's just not a web service for it anymore. You will be hosting the compiler locally, rather than making an API call for it.

There's no immediate plans to resolve this as hosting the compiler locally is trivial.

But longer-term, there will be an overall alternative.
 
That's because that's the link XF currently uses to try to minify JS. It was to demonstrate it doesn't work anymore.

You will need to search for "download closure compiler <your platform>" to download the compiler for your platform.
 
I found the binaries here:

Downloaded the most recent version into src/addons, and added to config.php:
Code:
$config['development']['closureCompilerPath'] = '/home/private_dev/src/addons/closure-compiler-v20200719.jar';
Unfortunately, that did not solve the issue for me, and still results in the same error.
 
There's no immediate plans to resolve this as hosting the compiler locally is trivial.

It's trivial once you figure out that's what you need to do, find where to download it, find the random config.php change to use it, install JRE so you can actually run it, etc.
 
Well this isn't good then. Guess my add-ons will have to be without minify now. I don't know enough about running my server to install anything and I sure don't wanna pay to have it installed for me. 🤦‍♂️
 
We're working on a replacement for 2.3.7. For now, assuming most of you aren't shipping thousands of lines of JS code, foregoing minification temporarily is certainly a viable option if using the closure compiler binary locally is not.
 
We're working on a replacement for 2.3.7. For now, assuming most of you aren't shipping thousands of lines of JS code, foregoing minification temporarily is certainly a viable option if using the closure compiler binary locally is not.
Great to hear! I'm pretty sure mine is probably like 50 lines, all add-ons combined, so probably not much savings using minify anyways. I just do it because...well...I'm not really sure why I do it. I guess cause that's what all the cool kids do. 🤣

Anyways, great to hear y'all are working on a solution. To read these forums sometimes, I kinda just thought y'all might always be on vacation. 🤣😂🤣 I kid, I kid!
 
Should be resolved in 2.3.7:

 
Back
Top Bottom