yiisoft / yii2-debug

Debug Extension for Yii 2
http://www.yiiframework.com
BSD 3-Clause "New" or "Revised" License
202 stars 149 forks source link

Please rewrite comments #494

Closed knoppixmeister closed 1 year ago

knoppixmeister commented 1 year ago

Is it possible/allowed to rewrite all "//" (double slashes) comments in assets/js/toolbar.js file (may be even somewhere else in other file(s)) into "/ ... /" style comments? Otherwise when we have minimized html output all JS scripts breaks because of this comments.

bizley commented 1 year ago

Hmm, isn't it a problem with the minimizer you are using?

knoppixmeister commented 1 year ago

I use following code in controller's init method for minimizing output on the fly

` class SiteController extends \yii\web\Controller { public function init() { parent::init();

        ob_start(function($b) {
            $res = preg_replace(['/\>[^\S ]+/s','/[^\S ]+\</s','/(\s)+/s'], ['>', '<', '\\1'], $b);
            $res = str_replace(["\r\n", "\n", "\r"], " ", $res);

            return $res;
        });

    }

.... .... `

So, because of all debug assets JS files injected directly in html output (not linked as separated JS files) the code above breaks overall JS work.

Also i already rewritten all js files for correct work in minimized mode in debug assets but it will break after package update thru composer.

Also there are few places where used "/ /" style commnets not "//"

bizley commented 1 year ago

It's clearly a problem on your side, you could just improve the preg_replace. I know that this change is super easy and should not impact anything but this is just wrong. Anyway @yiisoft/reviewers ?

samdark commented 1 year ago

Minimizer regex is to be fixed.