Hi Drupal folks,
Couple of moths ago i came across a rare issue with the JsOptimizer the generated .JS file was empty.
After a few hours of debugging i came across the JsOptimizer::clean regex and saw that it gave NULL back as return.
$contents = preg_replace('/\/\/(#|@)\s(sourceURL|sourceMappingURL)=\s*(\S*?)\s*$/m', '', $contents);
No errors or notices in the logging what so ever, but i guess it was the "Backtracking limit" that the issue because there where a lot of javascript files that was optimised to one file. So i decide to rewrite the preg_replace to this one:
$contents = preg_replace('/\/\/(#|@)\s(sourceURL|sourceMappingURL)=\s*[^$\s]*\s*$/m', '', $contents);
And everything was working, i didn't have a test case with sourceURL|sourceMappingURL so thats needs to be tested if the preg_replace is working. I added the patch in this issue that we are using right now with success.
PHP Version: 7.1.x
Drupal version: 8.5.x