This is an automated email from the ASF dual-hosted git repository.

benweidig pushed a commit to branch javax
in repository https://gitbox.apache.org/repos/asf/tapestry-5.git

commit 2d5509c3a464b81d4ac4abb123d1ff9656c19e41
Author: Ben Weidig <[email protected]>
AuthorDate: Sun Apr 12 16:52:11 2026 +0200

    webresources: GoogleClosureMinimizer reduce logging, improve error handling
    
    Trying to silence GoogleClosureMinimizer on unrelated problems, as it's
    currently only usable for whitespace removal without breaking a lot of
    modern JS.
    
    If something goes wrong, it will now return the non-minimized resource
    (plus logging) instead of throwing an exception.
---
 .../webresources/GoogleClosureMinimizer.java       |  8 +++----
 .../GoogleClosureMinimizerOptionsProviderImpl.java | 26 +++++++++++++++++-----
 2 files changed, 25 insertions(+), 9 deletions(-)

diff --git 
a/tapestry-webresources/src/main/java/org/apache/tapestry5/internal/webresources/GoogleClosureMinimizer.java
 
b/tapestry-webresources/src/main/java/org/apache/tapestry5/internal/webresources/GoogleClosureMinimizer.java
index f2385dccd..3db20fe17 100644
--- 
a/tapestry-webresources/src/main/java/org/apache/tapestry5/internal/webresources/GoogleClosureMinimizer.java
+++ 
b/tapestry-webresources/src/main/java/org/apache/tapestry5/internal/webresources/GoogleClosureMinimizer.java
@@ -50,7 +50,7 @@ public class GoogleClosureMinimizer extends AbstractMinimizer
 
     static
     {
-        Compiler.setLoggingLevel(Level.SEVERE);
+        Compiler.setLoggingLevel(Level.OFF);
     }
 
     public GoogleClosureMinimizer(Logger logger,
@@ -106,8 +106,8 @@ public class GoogleClosureMinimizer extends 
AbstractMinimizer
             return IOUtils.toInputStream(compiler.toSource(), 
StandardCharsets.UTF_8);
         }
 
-        throw new ResourceMinimizationException(String.format("Compilation 
failed for %s. Errors: %s.",
-                       resource,
-                InternalUtils.join(CollectionFactory.newList(result.errors), 
";")));
+        logger.warn("Compilation failed for {}. Errors: %{}", resource, 
InternalUtils.join(CollectionFactory.newList(result.errors), ";"));
+
+        return IOUtils.toInputStream(source, StandardCharsets.UTF_8);
     }
 }
diff --git 
a/tapestry-webresources/src/main/java/org/apache/tapestry5/internal/webresources/GoogleClosureMinimizerOptionsProviderImpl.java
 
b/tapestry-webresources/src/main/java/org/apache/tapestry5/internal/webresources/GoogleClosureMinimizerOptionsProviderImpl.java
index 8217574a1..1bdaeddc6 100644
--- 
a/tapestry-webresources/src/main/java/org/apache/tapestry5/internal/webresources/GoogleClosureMinimizerOptionsProviderImpl.java
+++ 
b/tapestry-webresources/src/main/java/org/apache/tapestry5/internal/webresources/GoogleClosureMinimizerOptionsProviderImpl.java
@@ -1,3 +1,15 @@
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
 package org.apache.tapestry5.internal.webresources;
 
 import java.util.Optional;
@@ -7,11 +19,13 @@ import 
org.apache.tapestry5.services.assets.StreamableResource;
 import org.apache.tapestry5.webresources.GoogleClosureMinimizerOptionsProvider;
 import org.apache.tapestry5.webresources.WebResourcesSymbols;
 
+import com.google.javascript.jscomp.BlackHoleErrorManager;
 import com.google.javascript.jscomp.CheckLevel;
-import com.google.javascript.jscomp.ClosureCodingConvention;
 import com.google.javascript.jscomp.CompilationLevel;
 import com.google.javascript.jscomp.CompilerOptions;
+import com.google.javascript.jscomp.DiagnosticGroup;
 import com.google.javascript.jscomp.DiagnosticGroups;
+import com.google.javascript.jscomp.deps.ModuleLoader;
 
 public class GoogleClosureMinimizerOptionsProviderImpl implements 
GoogleClosureMinimizerOptionsProvider
 {
@@ -29,12 +43,14 @@ public class GoogleClosureMinimizerOptionsProviderImpl 
implements GoogleClosureM
     {
         CompilerOptions options = new CompilerOptions();
 
-        options.setCodingConvention(new ClosureCodingConvention());
-        options.setWarningLevel(DiagnosticGroups.CHECK_VARIABLES, 
CheckLevel.WARNING);
-
         compilationLevel.setOptionsForCompilationLevel(options);
 
+        options.setLanguageIn(CompilerOptions.LanguageMode.UNSTABLE);
+        
options.setWarningLevel(DiagnosticGroup.forType(ModuleLoader.INVALID_MODULE_PATH),
 CheckLevel.OFF);
+        options.setWarningLevel(DiagnosticGroups.NON_STANDARD_JSDOC, 
CheckLevel.OFF);
+        options.setWarningLevel(DiagnosticGroups.PARSING, CheckLevel.OFF);
+        options.setErrorHandler(new BlackHoleErrorManager());
+
         return Optional.of(options);
     }
-
 }

Reply via email to