fix plugin loading in packed mode

pull/85/head
nightwing 2015-04-16 20:49:41 +04:00
rodzic 712400abc0
commit fa25550038
4 zmienionych plików z 33 dodań i 43 usunięć

Wyświetl plik

@ -1,4 +1,3 @@
console.time("req");
(function() {
var MODULE_LOAD_URL = "/load/module";
@ -288,40 +287,34 @@ require.MODULE_LOAD_URL = MODULE_LOAD_URL;
require.toUrl = function(moduleName, ext, skipExt) {
var absRe = /^([\w\+\.\-]+:|\/)/;
if (config.baseUrl) {
var index = moduleName.indexOf("!");
if (index !== -1 || !ext)
ext = "";
var paths = config.paths;
var pkgs = config.packages;
var index = moduleName.indexOf("!");
if (index !== -1 || !ext)
ext = "";
var testPath = moduleName, tail = "";
while (testPath) {
if (paths[testPath]) {
moduleName = paths[testPath] + tail;
break;
}
if (pkgs[testPath]) {
moduleName = pkgs[testPath].location + (tail || pkgs[testPath].main);
break;
}
var i = testPath.lastIndexOf("/");
if (i === -1) break;
tail = testPath.substr(i) + tail;
testPath = testPath.slice(0, i);
var paths = config.paths;
var pkgs = config.packages;
var testPath = moduleName, tail = "";
while (testPath) {
if (paths[testPath]) {
moduleName = paths[testPath] + tail;
break;
}
var url = moduleName + ext;
if (!absRe.test(url)) url = config.baseUrl + url;
return url;
if (pkgs[testPath]) {
moduleName = pkgs[testPath].location + (tail || pkgs[testPath].main);
break;
}
var i = testPath.lastIndexOf("/");
if (i === -1) break;
tail = testPath.substr(i) + tail;
testPath = testPath.slice(0, i);
}
var path = moduleName;
if (!absRe.test(path))
path = require.MODULE_LOAD_URL + "/" + path + (ext || "");
return path;
var url = moduleName + ext;
if (!absRe.test(url)) {
url = (config.baseUrl || require.MODULE_LOAD_URL + "/") + url;
}
return url;
};
var loadScript = function(path, id, callback) {

Wyświetl plik

@ -304,7 +304,7 @@ function resolveModuleId(id, paths) {
if (typeof alias == "string") {
return alias + tail;
} else if (alias) {
return alias.location + (tail || alias.main || alias.name);
return alias.location.replace(/\/*$/, "/") + (tail || alias.main || alias.name);
} else if (alias === false) {
return "";
}
@ -375,17 +375,15 @@ function wrapUMD(module) {
+ ' if (typeof name == "function") {\n'
+ ' m = name; deps = ["require", "exports", "module"]; name = _.module.id\n'
+ ' }\n'
+ ' if (typeof name == "object") {\n'
+ ' if (typeof name !== "string") {\n'
+ ' m = deps; deps = name; name = _.module.id\n'
+ ' }\n'
+ ' if (typeof deps == "function") {\n'
+ ' if (!m) {\n'
+ ' m = deps; deps = [];\n'
+ ' }\n'
+ ' if (typeof m != "function") {\n'
+ ' deps = m; m = null;\n'
+ ' }\n'
+ ' var ret = m ? m.apply(_.module, deps.map(function(n){return _[n] || require(n)})) : deps\n'
+ ' if (ret) _.module.exports = ret;\n'
+ ' var ret = typeof m == "function" ?\n'
+ ' m.apply(_.module, deps.map(function(n){return _[n] || require(n)})) : m\n'
+ ' if (ret != undefined) _.module.exports = ret;\n'
+ '}\n'
+ 'define.amd = true;'
+ module.source

Wyświetl plik

@ -187,8 +187,8 @@ define(function(require, exports, module) {
// Remove the base path
data = data.replace(rePath, "");
if (data.indexOf("/__installed__.js"))
next("installed");
if (data.indexOf("/__installed__.js") !== -1)
return next("installed");
// Process all the submodules
var parallel = processModules(path, data, resourceHolder);

Wyświetl plik

@ -106,8 +106,7 @@ function plugin(options, imports, register) {
var cdn = options.options.cdn;
options.options.themePrefix = "/static/" + cdn.version + "/skin/" + configName;
options.options.workerPrefix = "/static/" + cdn.version + "/worker";
if (req.params.packed == 1)
options.options.CORSWorkerPrefix = "/static/" + cdn.version + "/worker";
options.options.CORSWorkerPrefix = req.params.packed ? "/static/" + cdn.version + "/worker" : "";
var collab = options.collab && req.params.collab !== 0 && req.params.nocollab != 1;
var opts = extend({}, options);