Skip to content
Browse files

Add shim support

  • Loading branch information...
1 parent 4e0f899 commit 6522c1e31ed31a5432b7f1e866a7eb6eaab60483 @rbackhouse rbackhouse committed Nov 16, 2012
View
2 org.dojotoolkit.optimizer.amd.rhinoast/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Rhinoast
Bundle-SymbolicName: org.dojotoolkit.optimizer.amd.rhinoast
-Bundle-Version: 0.4.4
+Bundle-Version: 0.4.8
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Require-Bundle: org.dojotoolkit.optimizer
Import-Package: org.dojotoolkit.json,
View
BIN ...mizer.amd.rhinoast/org/dojotoolkit/optimizer/amd/rhinoast/AMDJSOptimizer$AstVisitor.class
Binary file not shown.
View
BIN ...optimizer.amd.rhinoast/org/dojotoolkit/optimizer/amd/rhinoast/AMDJSOptimizer$Module.class
Binary file not shown.
View
BIN ...oolkit.optimizer.amd.rhinoast/org/dojotoolkit/optimizer/amd/rhinoast/AMDJSOptimizer.class
Binary file not shown.
View
78 ...kit.optimizer.amd.rhinoast/src/org/dojotoolkit/optimizer/amd/rhinoast/AMDJSOptimizer.java
@@ -139,10 +139,11 @@ protected JSAnalysisDataImpl _getAnalysisData(String[] modules, JSAnalysisData[]
Map<String, List<Map<String, String>>> pluginRefs = new HashMap<String, List<Map<String, String>>>();
List<Map<String, Object>> missingNamesList = new ArrayList<Map<String, Object>>();
Map<String, Module> moduleMap = new HashMap<String, Module>();
+ Map<String, String> shims = new HashMap<String, String>();
for (String moduleId : modules) {
logger.logp(Level.INFO, getClass().getName(), "_getAnalysisData", "AST parsing ["+moduleId+"] using the Rhino AST API");
- AstVisitor visitor = new AstVisitor(moduleId, moduleMap, pluginRefs, missingNamesList, cfg, new Stack<String>(), excludeList, pageConfigString, scanCJSRequires);
+ AstVisitor visitor = new AstVisitor(moduleId, moduleMap, pluginRefs, missingNamesList, cfg, new Stack<String>(), excludeList, pageConfigString, scanCJSRequires, shims);
if (visitor.getError() != null) {
logger.logp(Level.INFO, getClass().getName(), "_getAnalysisData", "AST parsing error for ["+moduleId+"] error : "+visitor.getError());
throw new IOException("AST parsing error for ["+moduleId+"] error : "+visitor.getError());
@@ -164,7 +165,7 @@ protected JSAnalysisDataImpl _getAnalysisData(String[] modules, JSAnalysisData[]
scanForCircularDependencies(m, new Stack<String>(), moduleMap);
}
- jsAnalysisData = new JSAnalysisDataImpl(modules, dependencies, null, null, missingNamesList, pluginRefs, resourceLoader, JSAnalysisDataImpl.getExludes(exclude), pageConfig);
+ jsAnalysisData = new JSAnalysisDataImpl(modules, dependencies, null, null, missingNamesList, pluginRefs, resourceLoader, JSAnalysisDataImpl.getExludes(exclude), pageConfig, shims);
return jsAnalysisData;
}
@@ -361,7 +362,9 @@ private void scanForCircularDependencies(Module module, Stack<String> check, Map
private String pageConfigString = null;
private String error = null;
private boolean scanCJSRequires = false;
-
+ private boolean defineFound = false;
+ private Map<String, String> shims = null;
+
public AstVisitor(String moduleId,
Map<String, Module> moduleMap,
Map<String, List<Map<String, String>>> pluginRefList,
@@ -370,7 +373,8 @@ public AstVisitor(String moduleId,
Stack<String> pathStack,
List<String> excludeList,
String pageConfigString,
- boolean scanCJSRequires) {
+ boolean scanCJSRequires,
+ Map<String, String> shims) {
if (moduleId.equals("require") || moduleId.equals("exports") || moduleId.equals("module")) {
moduleMap.put(moduleId, new Module(moduleId, moduleId));
@@ -386,6 +390,7 @@ public AstVisitor(String moduleId,
this.excludeList = excludeList;
this.pageConfigString = pageConfigString;
this.scanCJSRequires = scanCJSRequires;
+ this.shims = shims;
this.baseUrl = (String)config.get("baseUrl");
@@ -415,7 +420,7 @@ public AstVisitor(String moduleId,
if (addDep) {
Stack<String> s = new Stack<String>();
s.push(this.moduleId);
- AstVisitor visitor = new AstVisitor(pluginDep, moduleMap, pluginRefList, missingNamesList, config, s, excludeList, pageConfigString, scanCJSRequires);
+ AstVisitor visitor = new AstVisitor(pluginDep, moduleMap, pluginRefList, missingNamesList, config, s, excludeList, pageConfigString, scanCJSRequires, shims);
if (visitor.getError() != null) {
error = visitor.getError();
return;
@@ -445,6 +450,9 @@ public AstVisitor(String moduleId,
try {
ast = parser.parse(source, this.moduleId, 1);
ast.visit(this);
+ if (!defineFound) {
+ findShim();
+ }
} catch (EvaluatorException e) {
error = "Failed to parse ["+url+"] [line:"+e.lineNumber()+" column:"+e.columnNumber()+"] reason ["+e.details()+"]";
}
@@ -468,12 +476,15 @@ public boolean visit(AstNode astNode) {
String callName = getCallName(target);
if (callName.equals("define") || callName.equals("require")) {
List<AstNode> args = functionCall.getArguments();
- if (callName.equals("define") && args.get(0) instanceof StringLiteral == false) {
- Map<String, Object> missingName = new HashMap<String, Object>();
- missingName.put("nameIndex", new Long(functionCall.getAbsolutePosition()+functionCall.getLp()+1));
- missingName.put("uri", url);
- missingName.put("id", this.moduleId);
- missingNamesList.add(missingName);
+ if (callName.equals("define")) {
+ defineFound = true;
+ if (args.get(0) instanceof StringLiteral == false) {
+ Map<String, Object> missingName = new HashMap<String, Object>();
+ missingName.put("nameIndex", new Long(functionCall.getAbsolutePosition()+functionCall.getLp()+1));
+ missingName.put("uri", url);
+ missingName.put("id", this.moduleId);
+ missingNamesList.add(missingName);
+ }
}
List<String> dependencies = new ArrayList<String>();
if (callName.equals("require") && args.get(0) instanceof StringLiteral) {
@@ -526,7 +537,7 @@ public boolean visit(AstNode astNode) {
}
if (addDep) {
module.dependencies.add(pluginDep);
- AstVisitor visitor = new AstVisitor(pluginDep, moduleMap, pluginRefList, missingNamesList, config, pathStack, excludeList, pageConfigString, scanCJSRequires);
+ AstVisitor visitor = new AstVisitor(pluginDep, moduleMap, pluginRefList, missingNamesList, config, pathStack, excludeList, pageConfigString, scanCJSRequires, shims);
if (visitor.getError() != null) {
error = visitor.getError();
return false;
@@ -559,7 +570,7 @@ public boolean visit(AstNode astNode) {
}
if (addDep) {
module.dependencies.add(dependencyId);
- AstVisitor visitor = new AstVisitor(dependencyId, moduleMap, pluginRefList, missingNamesList, config, pathStack, excludeList, pageConfigString, scanCJSRequires);
+ AstVisitor visitor = new AstVisitor(dependencyId, moduleMap, pluginRefList, missingNamesList, config, pathStack, excludeList, pageConfigString, scanCJSRequires, shims);
if (visitor.getError() != null) {
error = visitor.getError();
return false;
@@ -683,6 +694,47 @@ private String getCallName(AstNode target) {
}
return proxyReturn;
}
+
+ private void findShim() {
+ Map<String, Object> shimConfig = (Map<String, Object>)config.get("shim");
+ if (shimConfig != null) {
+ Map<String, Object> shim = (Map<String, Object>)shimConfig.get(moduleId);
+ if (shim != null) {
+ StringBuffer shimContent = new StringBuffer();
+ shimContent.append("\n(function(root, cfg) {\n");
+ shimContent.append("define('");
+ shimContent.append(moduleId);
+ shimContent.append("', ");
+ List<String> deps = (List<String>)shim.get("deps");
+ if (deps != null) {
+ shimContent.append("[");
+ for (String dep : deps) {
+ module.dependencies.add(dep);
+ shimContent.append("'");
+ shimContent.append(dep);
+ shimContent.append("',");
+ }
+ shimContent.deleteCharAt(shimContent.length()-1);
+ shimContent.append("], ");
+ }
+ shimContent.append("function() {\n");
+ String exports = (String)shim.get("exports");
+ if (shim.containsKey("init")) {
+ shimContent.append("\tvar initFunc = cfg.shim['"+moduleId+"'].init;\n");
+ shimContent.append("\tvar initRet = initFunc.apply(root, arguments);\n");
+ if (exports != null) {
+ shimContent.append("\tif (initRet) { return initRet; } else { return root." + exports + "; }\n");
+ } else {
+ shimContent.append("\tif (initRet) { return initRet; } else { return {}; }\n");
+ }
+ } else if (exports != null) {
+ shimContent.append("return root." + exports + ";\n");
+ }
+ shimContent.append("});\n}(this, zazl._getConfig()));\n");
+ shims.put(this.url, shimContent.toString());
+ }
+ }
+ }
}
private class Module {
View
2 org.dojotoolkit.optimizer.amd/META-INF/MANIFEST.MF
@@ -2,4 +2,4 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: AMD Optimizer
Bundle-SymbolicName: org.dojotoolkit.optimizer.amd;singleton:=true
-Bundle-Version: 0.4.6
+Bundle-Version: 0.4.8
View
29 org.dojotoolkit.optimizer.amd/loader/amd/zazl.js
@@ -228,7 +228,32 @@ var define;
if (window.dojoConfig && window.dojoConfig.locale) {
locale = dojoConfig.locale;
}
- var configString = JSON.stringify(cfg);
+ function clone(obj) {
+ if (null == obj || "object" != typeof obj) return obj;
+ if (obj instanceof Array) {
+ var copy = [];
+ var len = obj.length;
+ for (var i = 0; i < len; ++i) {
+ copy[i] = clone(obj[i]);
+ }
+ return copy;
+ }
+ if (obj instanceof Object) {
+ var copy = {};
+ for (var attr in obj) {
+ if (obj.hasOwnProperty(attr)) {
+ if (isFunction(obj[attr])) {
+ copy[attr] = "function";
+ } else {
+ copy[attr] = clone(obj[attr]);
+ }
+ }
+ }
+ return copy;
+ }
+ throw new Error("Unable to clone");
+ }
+ var configString = JSON.stringify(clone(cfg));
var url = cfg.injectUrl+"?modules=";
for (var i = 0; i < notLoaded.length; i++) {
url += notLoaded[i];
@@ -610,6 +635,8 @@ var define;
zazl.addToCache = function(id, value) {
precache[id] = value;
};
+
+ zazl._getConfig = function() { return cfg};
function processCache() {
for (var id in precache) {
View
5 org.dojotoolkit.optimizer.amd/optimizer/amd/AMDAnalyzer.js
@@ -94,9 +94,10 @@ AMDAnalyzer.prototype = {
_analyze: function(modules, exclude) {
this.pluginRefList = {};
this.missingNamesList = [];
+ this.shims = {};
this.moduleMap = map.createMap();
for (var i = 0; i < modules.length; i++) {
- astwalker.walker(modules[i], exclude, this.moduleMap, this.pluginRefList, this.missingNamesList, this.config, []);
+ astwalker.walker(modules[i], exclude, this.moduleMap, this.pluginRefList, this.missingNamesList, this.config, this.shims, []);
}
},
@@ -119,7 +120,7 @@ AMDAnalyzer.prototype = {
getAnalysisData: function(modules, exclude) {
var dependencyList = this.getDependencyList(modules, exclude);
- return ({dependencyList: dependencyList, pluginRefs: this.pluginRefList, missingNamesList: this.missingNamesList});
+ return ({dependencyList: dependencyList, pluginRefs: this.pluginRefList, missingNamesList: this.missingNamesList, shims: this.shims});
}
};
View
80 org.dojotoolkit.optimizer.amd/optimizer/amd/astwalker.js
@@ -248,7 +248,45 @@ function findDefine(ast) {
return expr;
};
-function esprimaWalker(uri, exclude, moduleMap, pluginRefList, missingNamesList, config, pathStack) {
+function findShim(module, config, shims) {
+ if (config.shim) {
+ var shim = config.shim[module.id];
+ if (shim) {
+ var shimContent = "\n(function(root, cfg) {\ndefine('";
+ shimContent += module.id;
+ shimContent += "', ";
+ if (shim.deps) {
+ shimContent += "[";
+ for (var i = 0; i < shim.deps.length; i++) {
+ module.addDependency(shim.deps[i]);
+ shimContent += "'";
+ shimContent += shim.deps[i];
+ shimContent += "'";
+ if (i < (shim.deps.length-1)) {
+ shimContent += ",";
+ }
+ }
+ shimContent += "], ";
+ }
+ shimContent += "function() {\n";
+ if (shim.init) {
+ shimContent += "\tvar initFunc = cfg.shim['"+module.id+"'].init;\n";
+ shimContent += "\tvar initRet = initFunc.apply(root, arguments);\n";
+ if (shim.exports) {
+ shimContent += "\tif (initRet) { return initRet; } else { return root." + shim.exports + "; }\n";
+ } else {
+ shimContent += "\tif (initRet) { return initRet; } else { return {}; }\n";
+ }
+ } else if (shim.exports) {
+ shimContent += "return root." + shim.exports + ";\n";
+ }
+ shimContent += "});\n}(this, zazl._getConfig()));\n";
+ shims[module.uri] = shimContent;
+ }
+ }
+};
+
+function esprimaWalker(uri, exclude, moduleMap, pluginRefList, missingNamesList, config, shims, pathStack) {
if (uri === "require" || uri === "exports" || uri === "module") {
moduleMap.add(uri, moduleCreator.createModule(uri, uri));
return;
@@ -275,7 +313,7 @@ function esprimaWalker(uri, exclude, moduleMap, pluginRefList, missingNamesList,
}
}
if (addDependency) {
- esprimaWalker(pluginRef.dependency, exclude, moduleMap, pluginRefList, missingNamesList, config, [uri]);
+ esprimaWalker(pluginRef.dependency, exclude, moduleMap, pluginRefList, missingNamesList, config, shims, [uri]);
}
}
pluginRefList[pluginName].push(pluginRef);
@@ -302,6 +340,10 @@ function esprimaWalker(uri, exclude, moduleMap, pluginRefList, missingNamesList,
var id = uri;
var module = moduleCreator.createModule(id, url);
moduleMap.add(uri, module);
+ if (defineExpr === undefined) {
+ findShim(module, config, shims);
+ return;
+ }
var depInfo = getDependencies(src, defineExpr, config.scanCJSRequires);
if (depInfo.nameIndex) {
missingNamesList.push({uri: url, id: id, nameIndex: depInfo.nameIndex});
@@ -338,7 +380,7 @@ function esprimaWalker(uri, exclude, moduleMap, pluginRefList, missingNamesList,
}
if (addDependency) {
module.addDependency(pluginRef.dependency);
- esprimaWalker(pluginRef.dependency, exclude, moduleMap, pluginRefList, missingNamesList, config, [dependency]);
+ esprimaWalker(pluginRef.dependency, exclude, moduleMap, pluginRefList, missingNamesList, config, shims, [dependency]);
}
}
pluginRefList[pluginName].push(pluginRef);
@@ -372,15 +414,15 @@ function esprimaWalker(uri, exclude, moduleMap, pluginRefList, missingNamesList,
}
if (addDependency) {
module.addDependency(dependency);
- esprimaWalker(dependency, exclude, moduleMap, pluginRefList, missingNamesList, config, pathStack);
+ esprimaWalker(dependency, exclude, moduleMap, pluginRefList, missingNamesList, config, shims, pathStack);
}
pathStack.pop();
}
}
}
};
-function uglifyjsWalker(uri, exclude, moduleMap, pluginRefList, missingNamesList, config, pathStack) {
+function uglifyjsWalker(uri, exclude, moduleMap, pluginRefList, missingNamesList, config, shims, pathStack) {
if (uri === "require" || uri === "exports" || uri === "module") {
moduleMap.add(uri, moduleCreator.createModule(uri, uri));
return;
@@ -410,7 +452,7 @@ function uglifyjsWalker(uri, exclude, moduleMap, pluginRefList, missingNamesList
}
}
if (addDependency) {
- uglifyjsWalker(pluginRef.dependency, exclude, moduleMap, pluginRefList, missingNamesList, config, [uri]);
+ uglifyjsWalker(pluginRef.dependency, exclude, moduleMap, pluginRefList, missingNamesList, config, shims, [uri]);
}
}
pluginRefList[pluginName].push(pluginRef);
@@ -436,14 +478,18 @@ function uglifyjsWalker(uri, exclude, moduleMap, pluginRefList, missingNamesList
var id = uri;
var module = moduleCreator.createModule(id, url);
moduleMap.add(uri, module);
+ var defineFound = false;
w.with_walkers({
"call": function(expr, args) {
if (expr[0] === "name" && (expr[1] === "define" || expr[1] === "require")) {
var dependencyArg;
- if (expr[1] === "define" && args[0][0].name !== "string") {
- var start = w.parent()[0].start;
- var nameIndex = start.pos + (src.substring(start.pos).indexOf('(')+1);
- missingNamesList.push({uri: url, id: id, nameIndex: nameIndex});
+ if (expr[1] === "define") {
+ defineFound = true;
+ if (args[0][0].name !== "string") {
+ var start = w.parent()[0].start;
+ var nameIndex = start.pos + (src.substring(start.pos).indexOf('(')+1);
+ missingNamesList.push({uri: url, id: id, nameIndex: nameIndex});
+ }
}
if (expr[1] === "require") {
if (args[0][0].name === "string" && config.scanCJSRequires) {
@@ -486,7 +532,7 @@ function uglifyjsWalker(uri, exclude, moduleMap, pluginRefList, missingNamesList
}
if (addDependency) {
module.addDependency(pluginRef.dependency);
- uglifyjsWalker(pluginRef.dependency, exclude, moduleMap, pluginRefList, missingNamesList, config, [dependency]);
+ uglifyjsWalker(pluginRef.dependency, exclude, moduleMap, pluginRefList, missingNamesList, config, shims, [dependency]);
}
}
pluginRefList[pluginName].push(pluginRef);
@@ -519,7 +565,7 @@ function uglifyjsWalker(uri, exclude, moduleMap, pluginRefList, missingNamesList
}
if (addDependency) {
module.addDependency(dependency);
- uglifyjsWalker(dependency, exclude, moduleMap, pluginRefList, missingNamesList, config, pathStack);
+ uglifyjsWalker(dependency, exclude, moduleMap, pluginRefList, missingNamesList, config, shims, pathStack);
}
pathStack.pop();
}
@@ -530,10 +576,14 @@ function uglifyjsWalker(uri, exclude, moduleMap, pluginRefList, missingNamesList
}, function(){
w.walk(ast);
});
+
+ if (defineFound === false) {
+ findShim(module, config, shims);
+ }
}
};
-function walker(uri, exclude, moduleMap, pluginRefList, missingNamesList, config, pathStack) {
+function walker(uri, exclude, moduleMap, pluginRefList, missingNamesList, config, shims, pathStack) {
if (!config.astparser) {
config.astparser = "uglifyjs";
}
@@ -545,10 +595,10 @@ function walker(uri, exclude, moduleMap, pluginRefList, missingNamesList, config
}
if (config.astparser === "uglifyjs") {
print("AST parsing ["+uri+"] using uglifyjs");
- uglifyjsWalker(uri, exclude, moduleMap, pluginRefList, missingNamesList, config, pathStack);
+ uglifyjsWalker(uri, exclude, moduleMap, pluginRefList, missingNamesList, config, shims, pathStack);
} else if (config.astparser === "esprima") {
print("AST parsing ["+uri+"] using esprima");
- esprimaWalker(uri, exclude, moduleMap, pluginRefList, missingNamesList, config, pathStack);
+ esprimaWalker(uri, exclude, moduleMap, pluginRefList, missingNamesList, config, shims, pathStack);
} else {
throw new Error("Unknown astparser value ["+config.astparser+"]");
}
View
2 org.dojotoolkit.optimizer.servlet/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Dojo Toolkit Optimizer Servlet
Bundle-SymbolicName: org.dojotoolkit.optimizer.servlet
-Bundle-Version: 0.4.6
+Bundle-Version: 0.4.8
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Import-Package: javax.servlet,
javax.servlet.http,
View
BIN org.dojotoolkit.optimizer.servlet/org/dojotoolkit/optimizer/servlet/AMDJSHandler.class
Binary file not shown.
View
7 org.dojotoolkit.optimizer.servlet/src/org/dojotoolkit/optimizer/servlet/AMDJSHandler.java
@@ -85,6 +85,7 @@ protected void customHandle(HttpServletRequest request, Writer handlerWriter, JS
Util.writeAMDLocalizations(resourceLoader, writer, localizations, request.getLocale());
}
Map<String, Integer> offsetMap = new HashMap<String, Integer>();
+ Map<String, String> shims = analysisData.getShims();
for (String dependency : dependencies) {
String path = Util.normalizePath(dependency);
String content = resourceLoader.readResource(path);
@@ -98,6 +99,12 @@ protected void customHandle(HttpServletRequest request, Writer handlerWriter, JS
modifiedSrc.append(content.substring(missingNameIndex));
content = modifiedSrc.toString();
}
+ if (shims != null) {
+ String shim = shims.get(uri);
+ if (shim != null) {
+ content += shim;
+ }
+ }
content = compressorContentFilter.filter(content,path);
int offset = writer.getLineCount();
offsetMap.put(path, new Integer(offset));
View
2 org.dojotoolkit.optimizer/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Optimizer
Bundle-SymbolicName: org.dojotoolkit.optimizer
-Bundle-Version: 0.4.7
+Bundle-Version: 0.4.8
Import-Package: org.dojotoolkit.json,
org.dojotoolkit.server.util.resource,
org.dojotoolkit.server.util.rhino
View
BIN org.dojotoolkit.optimizer/org/dojotoolkit/optimizer/JSAnalysisData.class
Binary file not shown.
View
BIN org.dojotoolkit.optimizer/org/dojotoolkit/optimizer/JSAnalysisDataImpl.class
Binary file not shown.
View
4 org.dojotoolkit.optimizer/src/org/dojotoolkit/optimizer/JSAnalysisData.java
@@ -49,4 +49,8 @@
* @return Map of plugin references include any optimized values
*/
Map<String, List<Map<String, String>>> getPluginRefs();
+ /**
+ * @return Module Shims
+ */
+ Map<String, String> getShims();
}
View
20 org.dojotoolkit.optimizer/src/org/dojotoolkit/optimizer/JSAnalysisDataImpl.java
@@ -12,6 +12,7 @@
import java.io.FileWriter;
import java.io.IOException;
import java.io.Reader;
+import java.io.StringReader;
import java.io.StringWriter;
import java.io.Writer;
import java.math.BigInteger;
@@ -44,6 +45,7 @@
private String key = null;
private String config = null;
private boolean checksumStale = false;
+ private Map<String, String> shims = null;
public JSAnalysisDataImpl(String[] modules,
List<String> dependencies,
@@ -53,8 +55,9 @@ public JSAnalysisDataImpl(String[] modules,
Map<String, List<Map<String, String>>> pluginRefs,
ResourceLoader resourceLoader,
String[] excludes,
- Map<String, Object> pageConfig) throws IOException {
- this(modules, dependencies, localizations, textDependencies, modulesMissingNames, pluginRefs, resourceLoader, excludes, pageConfig, null, null);
+ Map<String, Object> pageConfig,
+ Map<String, String> shims) throws IOException {
+ this(modules, dependencies, localizations, textDependencies, modulesMissingNames, pluginRefs, resourceLoader, excludes, pageConfig, shims, null, null);
}
private JSAnalysisDataImpl(String[] modules,
@@ -66,6 +69,7 @@ private JSAnalysisDataImpl(String[] modules,
ResourceLoader resourceLoader,
String[] excludes,
Map<String, Object> pageConfig,
+ Map<String, String> shims,
String checksum,
String config) throws IOException {
timestampLookup = new HashMap<String, Long>();
@@ -88,6 +92,7 @@ private JSAnalysisDataImpl(String[] modules,
this.pluginRefs = pluginRefs;
this.resourceLoader = resourceLoader;
this.excludes = excludes;
+ this.shims = shims;
if (pageConfig != null) {
StringWriter sw = new StringWriter();
try {
@@ -139,6 +144,10 @@ public String getKey() {
return key;
}
+ public Map<String, String> getShims() {
+ return shims;
+ }
+
public boolean isStale() {
if (checksumStale) {
return true;
@@ -196,6 +205,9 @@ public void save(File tempDir) {
if (config != null) {
implDetails.put("pageConfig", config);
}
+ if (shims != null) {
+ implDetails.put("shims", shims);
+ }
JSONSerializer.serialize(w, implDetails, true);
} catch (IOException e) {
logger.logp(Level.SEVERE, JSAnalysisDataImpl.class.getName(), "load", "Failed to save ["+implFile.getPath()+"]", e);
@@ -241,15 +253,17 @@ public static JSAnalysisDataImpl load(String key, File tempDir, ResourceLoader r
}
String config = (String)implDetails.get("pageConfig");
String checksum = (String)implDetails.get("checksum");
+ Map<String, String> shims = (Map<String, String>)implDetails.get("shims");
impl = new JSAnalysisDataImpl(modules,
dependencies,
localizations,
textDependencies,
modulesMissingNames,
pluginRefs,
resourceLoader,
- excludes,
+ excludes,
null,
+ shims,
checksum,
config);
} catch (IOException e) {

0 comments on commit 6522c1e

Please sign in to comment.
Something went wrong with that request. Please try again.