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 2012/07/14 01:43:07 UTC
[6/7] git commit: Set a long timeout when in development mode (in
case developer is debugging) Handle special case where the module name
includes a '.' in the name
Set a long timeout when in development mode (in case developer is debugging)
Handle special case where the module name includes a '.' in the name
Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/0773b41c
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/0773b41c
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/0773b41c
Branch: refs/heads/5.4-js-rewrite
Commit: 0773b41cc83ede0ded64ba6599099f88d724352d
Parents: 98a68ad
Author: Howard M. Lewis Ship <hl...@apache.org>
Authored: Fri Jul 13 15:57:11 2012 -0700
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Fri Jul 13 15:57:11 2012 -0700
----------------------------------------------------------------------
.../services/javascript/ModuleManagerImpl.java | 28 +++++++++-----
1 files changed, 18 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/0773b41c/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/javascript/ModuleManagerImpl.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/javascript/ModuleManagerImpl.java b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/javascript/ModuleManagerImpl.java
index 5571fdd..a3894e5 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/javascript/ModuleManagerImpl.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/javascript/ModuleManagerImpl.java
@@ -64,14 +64,17 @@ public class ModuleManagerImpl implements ModuleManager
@Path("${" + SymbolConstants.REQUIRE_JS + "}")
Asset requireJS,
Map<String, ShimModule> configuration,
- Messages globalMessages, @Symbol(SymbolConstants.COMPACT_JSON)
- boolean compactJSON)
+ Messages globalMessages,
+ @Symbol(SymbolConstants.COMPACT_JSON)
+ boolean compactJSON,
+ @Symbol(SymbolConstants.PRODUCTION_MODE)
+ boolean productionMode)
{
this.requireJS = requireJS;
this.globalMessages = globalMessages;
this.compactJSON = compactJSON;
- this.requireConfig = buildRequireJSConfig(constructor.constructAssetPath("module-root", ""), configuration);
+ this.requireConfig = buildRequireJSConfig(constructor.constructAssetPath("module-root", ""), configuration, !productionMode);
classpathRoot = assetSource.resourceForPath("");
@@ -97,10 +100,15 @@ public class ModuleManagerImpl implements ModuleManager
libraryNameToPackageNames.put("app", resolver.getPackagesForLibrary(""));
}
- private String buildRequireJSConfig(String baseURL, Map<String, ShimModule> configuration)
+ private String buildRequireJSConfig(String baseURL, Map<String, ShimModule> configuration, boolean devMode)
{
- JSONObject shims = new JSONObject();
- JSONObject config = new JSONObject().put("baseUrl", baseURL).put("shim", shims);
+ JSONObject config = new JSONObject().put("baseUrl", baseURL);
+
+ // In DevMode, wait up to five minutes for a script, as the developer may be using the debugger.
+ if (devMode)
+ {
+ config.put("waitSeconds", 300);
+ }
for (String name : configuration.keySet())
{
@@ -108,7 +116,7 @@ public class ModuleManagerImpl implements ModuleManager
shimModuleNameToResource.put(name, module.resource);
- JSONObject shim = new JSONObject();
+ JSONObject shim = config.in("shim").in(name);
if (module.dependencies != null && !module.dependencies.isEmpty())
{
@@ -122,8 +130,6 @@ public class ModuleManagerImpl implements ModuleManager
{
shim.put("exports", module.exports);
}
-
- shims.put(name, shim);
}
return String.format("require.config(%s);\n",
@@ -212,7 +218,9 @@ public class ModuleManagerImpl implements ModuleManager
for (String p : packages)
{
- String baseName = p.replace('.', '/') + "/modulejs/" + extra;
+ // Tack on a fake extension; otherwise modules whose name includes a '.' get mangled
+ // by Resource.withExtension().
+ String baseName = p.replace('.', '/') + "/modulejs/" + extra + ".EXT";
Resource baseResource = classpathRoot.forFile(baseName);