Skip to content

keep package inputs ES5-compatible - #15

Merged
tomfotherby merged 1 commit into
masterfrom
bbq_arrow_function_issue
May 17, 2026
Merged

keep package inputs ES5-compatible#15
tomfotherby merged 1 commit into
masterfrom
bbq_arrow_function_issue

Conversation

@tomfotherby

@tomfotherby tomfotherby commented May 17, 2026

Copy link
Copy Markdown
Member

In our project, with the latest version of yii, we have a failing input lib/pph-yii-repo/framework/web/js/source/jquery.ba-bbq.min.js:23 because that minified file contained ES6 arrow IIFEs and unquoted reserved object keys, which YUI Compressor 2.4.8 cannot parse.

YUI Compressor 2.4.8 is still the latest official YUI Compressor release, published in 2014. YUI Compressor parses JS through Rhino, and the official project predates ES6 syntax support like arrow functions. So there is no drop-in yuicompressor-2.4.9.jar or newer official jar that will parse =>.


During our Build step, when CircleCI runs the following command:

docker run -t --rm --volumes-from dc --memory=3g --env APP_ID=next --env CLIENTSCRIPT_CDN=https://staging.peopleperhour.com --env S3_BUCKET_MAIN=pphuserfilesstaging --env S3_BUCKET_MAIN_KEY=$IAM_KEY_S3_STAGING_YII_ASSETS --env S3_BUCKET_MAIN_SECRET=$IAM_SECRET_S3_STAGING_YII_ASSETS peopleperhour/pph_builder:7.4_24cd068e php /var/www/pph/yiic.php pkgcomp compressAll

We get a error:

There are 35 packages to compress. The global state key will be '__packageCompressor:next'.
 1 ] compressing css-white-lion...            done. (Time taken so far: 8s)
 2 ] compressing header-minimal...            [ERROR] in /var/www/pph/var/tmp/combined_header-minimalU11efg
  23:5:syntax error
[ERROR] in /var/www/pph/var/tmp/combined_header-minimalU11efg
  23:341:illegal character
[ERROR] in /var/www/pph/var/tmp/combined_header-minimalU11efg
  23:341:syntax error
[ERROR] in /var/www/pph/var/tmp/combined_header-minimalU11efg
  23:343:illegal character
[ERROR] in /var/www/pph/var/tmp/combined_header-minimalU11efg
  23:345:syntax error
[ERROR] in /var/www/pph/var/tmp/combined_header-minimalU11efg
  23:3143:invalid property id
[ERROR] in /var/www/pph/var/tmp/combined_header-minimalU11efg
  23:5461:syntax error
[ERROR] in /var/www/pph/var/tmp/combined_header-minimalU11efg
  23:6645:syntax error
[ERROR] in /var/www/pph/var/tmp/combined_header-minimalU11efg
  1:0:Compilation produced 8 syntax errors.
org.mozilla.javascript.EvaluatorException: Compilation produced 8 syntax errors.
        at com.yahoo.platform.yui.compressor.YUICompressor$1.runtimeError(YUICompressor.java:193)
        at org.mozilla.javascript.Parser.parse(Parser.java:396)
        at org.mozilla.javascript.Parser.parse(Parser.java:340)
        at com.yahoo.platform.yui.compressor.JavaScriptCompressor.parse(JavaScriptCompressor.java:315)
        at com.yahoo.platform.yui.compressor.JavaScriptCompressor.<init>(JavaScriptCompressor.java:540)
        at com.yahoo.platform.yui.compressor.YUICompressor.main(YUICompressor.java:168)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at com.yahoo.platform.yui.compressor.Bootstrap.main(Bootstrap.java:21)
CException: Could not create compressed js file. Maybe missing a JRE?
Command was:
'java' -jar '/var/www/pph/lib/yui-compressor/yuicompressor-2.4.8-master.jar' --type js -o '/var/www/pph/var/tmp/js_pkg_header-minimal_0e635f6d8478d5ab0c1de99d6aecaa41.js' '/var/www/pph/var/tmp/combined_header-minimalU11efg' in /var/www/pph/components/ClientScriptPackageCompressor.php:732
Stack trace:
#0 /var/www/pph/components/ClientScriptPackageCompressor.php(224): ClientScriptPackageCompressor->compressFiles('header-minimal', 'js', Array)
#1 /var/www/pph/commands/PkgCompCommand.php(97): ClientScriptPackageCompressor->compressPackage('header-minimal')
#2 /var/www/pph/commands/PkgCompCommand.php(113): PkgCompCommand->actionCompress('header-minimal')
#3 [internal function]: PkgCompCommand->actionCompressAll()
#4 /var/www/pph/lib/pph-yii-repo/framework/console/CConsoleCommand.php(177): ReflectionMethod->invokeArgs(Object(PkgCompCommand), Array)
#5 /var/www/pph/lib/pph-yii-repo/framework/console/CConsoleCommandRunner.php(71): CConsoleCommand->run(Array)
#6 /var/www/pph/lib/pph-yii-repo/framework/console/CConsoleApplication.php(92): CConsoleCommandRunner->run(Array)
#7 /var/www/pph/lib/pph-yii-repo/framework/base/CApplication.php(185): CConsoleApplication->processRequest()
#8 /var/www/pph/lib/pph-yii-repo/framework/yiic.php(33): CApplication->run()
#9 /var/www/pph/yiic.php(17): require_once('/var/www/pph/li...')
#10 {main}
Exited with code exit status 1

I noticed the clientscript package that has the problem is defined in @config/clientscript.php

        'header-minimal' => [
            'baseUrl'   => '/',
            's3'        => true,
            'cdn'       => true,
            'css'       => [
                'css/appmini.css',
            ],
            'js'=>[
                'js/pph/pph.js',
                'js/pph/pph.activeform.js',
                'js/pph/pph.common.js',
                'js/pph/pph.availability-switch.js',
                'js/pph/pph.switch.js',
                'js/pph/pph.modules.FeatureFeedback.js',
                'js/pph/pph.modules.Notifications.js',
                'js/pph/pph.modules.SubscribeNewsletter.js',
//                'js/pph-externals/vendor/pusher/dist/web/pusher.js',
//                'js/pph/pph.pusher.js',
                'js/pph/pph.modules.Rtm.js',
                'js/pph-externals/vendor/bootstrap/dist/js/bootstrap.js',
                'js/pph/responsive/pph.bootstrap.js',
            ],
            'depends'=>[
                'bbq',
                'cookie',
                'yiiactiveform',
                'pph-external-jslibs-minimal',
            ],
        ],

Reference: https://github.com/yui/yuicompressor/releases

@tomfotherby
tomfotherby merged commit 5d8a444 into master May 17, 2026
0 of 30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant