You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2013/11/11 21:05:09 UTC

[3/3] git commit: TAP5-2221: Aggregated JavaScript stacks are not passed through the JavaScript minimizer

TAP5-2221: Aggregated JavaScript stacks are not passed through the JavaScript minimizer


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/8b5e3530
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/8b5e3530
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/8b5e3530

Branch: refs/heads/master
Commit: 8b5e3530dcb0cffd580dfa0ba21b4bff4c06714d
Parents: 6449188
Author: Howard M. Lewis Ship <hl...@apache.org>
Authored: Mon Nov 11 12:04:58 2013 -0800
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Mon Nov 11 12:04:58 2013 -0800

----------------------------------------------------------------------
 .../assets/JavaScriptStackAssemblerImpl.java    | 23 ++++++++++++++++++--
 .../tapestry5/modules/JavaScriptModule.java     |  9 +++++++-
 .../services/javascript/StackExtensionType.java |  4 ++++
 3 files changed, 33 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/8b5e3530/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/assets/JavaScriptStackAssemblerImpl.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/assets/JavaScriptStackAssemblerImpl.java b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/assets/JavaScriptStackAssemblerImpl.java
index 5cce91b..d7b426e 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/assets/JavaScriptStackAssemblerImpl.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/assets/JavaScriptStackAssemblerImpl.java
@@ -15,7 +15,9 @@
 package org.apache.tapestry5.internal.services.assets;
 
 import org.apache.tapestry5.Asset;
+import org.apache.tapestry5.SymbolConstants;
 import org.apache.tapestry5.ioc.Resource;
+import org.apache.tapestry5.ioc.annotations.Symbol;
 import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
 import org.apache.tapestry5.ioc.services.ThreadLocale;
 import org.apache.tapestry5.services.assets.*;
@@ -45,11 +47,19 @@ public class JavaScriptStackAssemblerImpl implements JavaScriptStackAssembler
 
     private final ModuleManager moduleManager;
 
+    private final ResourceMinimizer resourceMinimizer;
+
+    private final boolean minificationEnabled;
+
     private final Map<String, StreamableResource> cache = CollectionFactory.newCaseInsensitiveMap();
 
     // TODO: Support for aggregated CSS as well as aggregated JavaScript
 
-    public JavaScriptStackAssemblerImpl(ThreadLocale threadLocale, ResourceChangeTracker resourceChangeTracker, StreamableResourceSource streamableResourceSource, JavaScriptStackSource stackSource, AssetChecksumGenerator checksumGenerator, ModuleManager moduleManager)
+    public JavaScriptStackAssemblerImpl(ThreadLocale threadLocale, ResourceChangeTracker resourceChangeTracker, StreamableResourceSource streamableResourceSource,
+                                        JavaScriptStackSource stackSource, AssetChecksumGenerator checksumGenerator, ModuleManager moduleManager,
+                                        ResourceMinimizer resourceMinimizer,
+                                        @Symbol(SymbolConstants.MINIFICATION_ENABLED)
+                                        boolean minificationEnabled)
     {
         this.threadLocale = threadLocale;
         this.resourceChangeTracker = resourceChangeTracker;
@@ -57,6 +67,8 @@ public class JavaScriptStackAssemblerImpl implements JavaScriptStackAssembler
         this.stackSource = stackSource;
         this.checksumGenerator = checksumGenerator;
         this.moduleManager = moduleManager;
+        this.resourceMinimizer = resourceMinimizer;
+        this.minificationEnabled = minificationEnabled;
 
         resourceChangeTracker.clearOnInvalidation(cache);
     }
@@ -210,6 +222,13 @@ public class JavaScriptStackAssemblerImpl implements JavaScriptStackAssembler
             assembly.add(resource, new ModuleReader(moduleName));
         }
 
-        return assembly.finish();
+        StreamableResource streamable = assembly.finish();
+
+        if (minificationEnabled)
+        {
+            return resourceMinimizer.minimize(streamable);
+        }
+
+        return streamable;
     }
 }

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/8b5e3530/tapestry-core/src/main/java/org/apache/tapestry5/modules/JavaScriptModule.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/modules/JavaScriptModule.java b/tapestry-core/src/main/java/org/apache/tapestry5/modules/JavaScriptModule.java
index 25e2f77..e1b4a68 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/modules/JavaScriptModule.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/modules/JavaScriptModule.java
@@ -90,8 +90,10 @@ public class JavaScriptModule
      * <dt>t5/core/init</dt> <dd>Optional module related to t53-compatibility.js</dd>
      * <dt>bootstrap.css, tapestry.css, exception-frame.css, tapestry-console.css, tree.css</dt>
      * <dd>CSS files</dd>
-     * <dt>t5/core/ajax, dom, events, console, exception-frame, pageinit, messages, utils</dt>
+     * <dt>t5/core/[ajax, dom, events, console, exception-frame, pageinit, messages, utils]</dt>
      * <dd>Additional JavaScript modules</dd>
+     * <dt>jquery</dt>
+     * <dd>Added if the infrastructure provider is "jquery".</dd>
      * </dl>
      * <p/>
      * User modules may replace or extend this list.
@@ -139,6 +141,11 @@ public class JavaScriptModule
             String full = "t5/core/" + name;
             configuration.add(full, new StackExtension(StackExtensionType.MODULE, full));
         }
+
+        if (provider.equals("jquery"))
+        {
+            add(configuration, StackExtensionType.MODULE, "jquery");
+        }
     }
 
     private static void add(OrderedConfiguration<StackExtension> configuration, StackExtensionType type, String... paths)

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/8b5e3530/tapestry-core/src/main/java/org/apache/tapestry5/services/javascript/StackExtensionType.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/services/javascript/StackExtensionType.java b/tapestry-core/src/main/java/org/apache/tapestry5/services/javascript/StackExtensionType.java
index 50594ae..6bb1c47 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/services/javascript/StackExtensionType.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/services/javascript/StackExtensionType.java
@@ -63,6 +63,10 @@ public enum StackExtensionType
      * Note that this only loads the module's <em>code</em> and defines the module as available;
      * the module's function will not be invoked unless {@link JavaScriptSupport#require(String)} is invoked to establish
      * a dependency.
+     * <p/>
+     * Note that at this time, {@linkplain JavaScriptModuleConfiguration#exports(String) shimmed modules} can not
+     * be aggregated into stacks properly; the shimmed module will be aggregated, but then will still be loaded via
+     * a subsequent HTTP request.
      *
      * @since 5.4
      */