mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 14:52:41 +01:00
T15774: Celerity: javascript minification issue with template literals (backticked strings)
Test Plan: This archive contains a small demo: {F2142567} When installed, an application named D25571 appears under "More Applications". When you start it, you will see 2 messageboxes: one should be a single lined text, the other a multilined text. Steps: 1) unpack archive in some directory 2) add ext-D25571/src/ path to load-libraries in local.json 3) bin/arc liberate 4) bin/cache purge --all 5) bin/celerity map 6) restart httpd 7) start D25571 application from More Applications Also: arc unit ./src/applications/celerity/__tests__/CelerityResourceTransformerTestCase.php Reviewers: O1 Blessed Committers, valerio.bozzolan Reviewed By: O1 Blessed Committers, valerio.bozzolan Subscribers: avivey, aklapper, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Maniphest Tasks: T15774 Differential Revision: https://we.phorge.it/D25571
This commit is contained in:
parent
c1d86da5b2
commit
214988fafd
1 changed files with 7 additions and 4 deletions
11
externals/JsShrink/jsShrink.php
vendored
11
externals/JsShrink/jsShrink.php
vendored
|
@ -11,7 +11,8 @@
|
||||||
function jsShrink($input) {
|
function jsShrink($input) {
|
||||||
return preg_replace_callback('(
|
return preg_replace_callback('(
|
||||||
(?:
|
(?:
|
||||||
(^|[-+\([{}=,:;!%^&*|?~]|/(?![/*])|return|throw) # context before regexp
|
(`(?:\\\\.|[^`\\\\])*`) # template literal
|
||||||
|
|(^|[-+\([{}=,:;!%^&*|?~]|/(?![/*])|return|throw) # context before regexp
|
||||||
(?:\s|//[^\n]*+\n|/\*(?:[^*]|\*(?!/))*+\*/)* # optional space
|
(?:\s|//[^\n]*+\n|/\*(?:[^*]|\*(?!/))*+\*/)* # optional space
|
||||||
(/(?![/*])(?:
|
(/(?![/*])(?:
|
||||||
\\\\[^\n]
|
\\\\[^\n]
|
||||||
|
@ -31,9 +32,11 @@ function jsShrink($input) {
|
||||||
|
|
||||||
function jsShrinkCallback($match) {
|
function jsShrinkCallback($match) {
|
||||||
static $last = '';
|
static $last = '';
|
||||||
$match += array_fill(1, 5, null); // avoid E_NOTICE
|
$match += array_fill(1, 7, null); // avoid E_NOTICE
|
||||||
list(, $context, $regexp, $result, $word, $operator) = $match;
|
list(, $template, $context, $regexp, $result, $word, $operator) = $match;
|
||||||
if ($word != '') {
|
if ($template) {
|
||||||
|
$result = $template;
|
||||||
|
} elseif ($word != '') {
|
||||||
$result = ($last == 'word' ? "\n" : ($last == 'return' ? " " : "")) . $result;
|
$result = ($last == 'word' ? "\n" : ($last == 'return' ? " " : "")) . $result;
|
||||||
$last = ($word == 'return' || $word == 'throw' || $word == 'break' || $word == 'async' ? 'return' : 'word');
|
$last = ($word == 'return' || $word == 'throw' || $word == 'break' || $word == 'async' ? 'return' : 'word');
|
||||||
} elseif ($operator) {
|
} elseif ($operator) {
|
||||||
|
|
Loading…
Reference in a new issue