src/Neutrino/Assets/ClosureCompiler.php
public function compile(array $options)
    {
        $jsCode = $this->extractJsCode($options['compile']['directories']);
        $jsCode = $this->applyPrecompilation($jsCode, isset($options['precompilations']) ? $options['precompilations'] : []);

        $data = [
          'compilation_level' => $options['compile']['level'],
          'output_format' => 'json',
          'output_info' => ['warnings', 'errors', 'statistics', 'compiled_code'],
          'warning_level' => 'default',
        ];

        if (!empty($options['compile']['externs_url'])) {
            $data['externs_url'] = $options['compile']['externs_url'];
        }

        if (!empty($options['compile']['js_externs'])) {
            $data['js_externs'] = $this->extractJsCode($options['compile']['js_externs']);
        }

        $query = http_build_query(['js_code' => $jsCode]) . '&' . preg_replace('/%5B[0-9]+%5D/simU', '', http_build_query($data));

        $request = Factory::makeRequest();
        $request
            ->setMethod(Method::POST)
            ->setUri('https://closure-compiler.appspot.com/compile')
            ->setParams($query)
            ->disableSsl();

        $response = $request->send();

        if (!$response->isOk()) {
            throw new CompilatorException(
                "Can't call closure compile api.\n" .
                "HTTP Status : {$response->getHeader()->get('Status')}\n" .
                "HTTP Erreur : [{$response->getErrorCode()}]: {$response->getError()}\n" .
                "HTTP Body   : {$response->getBody()}"
            );
        }

        $content = $response->parse(JsonArray::class)->getData();

        file_put_contents(BASE_PATH . '/' . $options['output_file'], $content['compiledCode']);

        unset($content['compiledCode']);

        return $content;
    }
public function compile(array $options)
    {
        $jsCode = $this->extractJsCode($options['compile']['directories']);
        $jsCode = $this->applyPrecompilation($jsCode, isset($options['precompilations']) ? $options['precompilations'] : []);

        $data = [
          'compilation_level' => $options['compile']['level'],
          'output_format' => 'json',
          'output_info' => ['warnings', 'errors', 'statistics', 'compiled_code'],
          'warning_level' => 'default',
        ];

        if (!empty($options['compile']['externs_url'])) {
            $data['externs_url'] = $options['compile']['externs_url'];
        }

        if (!empty($options['compile']['js_externs'])) {
            $data['js_externs'] = $this->extractJsCode($options['compile']['js_externs']);
        }

        $query = http_build_query(['js_code' => $jsCode]) . '&' . preg_replace('/%5B[0-9]+%5D/simU', '', http_build_query($data));

        $request = Factory::makeRequest();
        $request
            ->setMethod(Method::POST)
            ->setUri('https://closure-compiler.appspot.com/compile')
            ->setParams($query)
            ->disableSsl();

        $response = $request->send();

        if (!$response->isOk()) {
            throw new CompilatorException(
                "Can't call closure compile api.\n" .
                "HTTP Status : {$response->getHeader()->get('Status')}\n" .
                "HTTP Erreur : [{$response->getErrorCode()}]: {$response->getError()}\n" .
                "HTTP Body   : {$response->getBody()}"
            );
        }

        $content = $response->parse(JsonArray::class)->getData();

        file_put_contents(BASE_PATH . '/' . $options['output_file'], $content['compiledCode']);

        unset($content['compiledCode']);

        return $content;
    }
@param array $options

@return mixed
@throws CompilatorException
@throws \Exception