Merge pull request #862 from ajaxorg/fix/requirejs_conflict
Fix/requirejs conflict
This commit is contained in:
commit
5e1c1457d6
4 changed files with 101 additions and 87 deletions
|
|
@ -43,7 +43,7 @@ if (!fs.existsSync)
|
||||||
var copy = require('dryice').copy;
|
var copy = require('dryice').copy;
|
||||||
|
|
||||||
var ACE_HOME = __dirname;
|
var ACE_HOME = __dirname;
|
||||||
var BUILD_DIR = "build";
|
var BUILD_DIR = ACE_HOME + "/build";
|
||||||
|
|
||||||
function main(args) {
|
function main(args) {
|
||||||
var type = "minimal";
|
var type = "minimal";
|
||||||
|
|
@ -146,16 +146,16 @@ function ace() {
|
||||||
console.log('# ace License | Readme | Changelog ---------');
|
console.log('# ace License | Readme | Changelog ---------');
|
||||||
|
|
||||||
copy({
|
copy({
|
||||||
source: "build_support/editor.html",
|
source: ACE_HOME + "/build_support/editor.html",
|
||||||
dest: "build/editor.html"
|
dest: BUILD_DIR + "/editor.html"
|
||||||
});
|
});
|
||||||
copy({
|
copy({
|
||||||
source: ACE_HOME + "/LICENSE",
|
source: ACE_HOME + "/LICENSE",
|
||||||
dest: "build/LICENSE"
|
dest: BUILD_DIR + "/LICENSE"
|
||||||
});
|
});
|
||||||
copy({
|
copy({
|
||||||
source: ACE_HOME + "/ChangeLog.txt",
|
source: ACE_HOME + "/ChangeLog.txt",
|
||||||
dest: "build/ChangeLog.txt"
|
dest: BUILD_DIR + "/ChangeLog.txt"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -164,13 +164,14 @@ function demo() {
|
||||||
|
|
||||||
var version, ref;
|
var version, ref;
|
||||||
try {
|
try {
|
||||||
version = JSON.parse(fs.readFileSync(__dirname + "/package.json")).version;
|
version = JSON.parse(fs.readFileSync(ACE_HOME + "/package.json")).version;
|
||||||
ref = fs.readFileSync(__dirname + "/.git-ref").toString();
|
ref = fs.readFileSync(ACE_HOME + "/.git-ref").toString();
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
ref = "";
|
ref = "";
|
||||||
version = "";
|
version = "";
|
||||||
}
|
}
|
||||||
var changeComments = function(data) {
|
|
||||||
|
function changeComments(data) {
|
||||||
return (data
|
return (data
|
||||||
.replace(/<!\-\-DEVEL[\d\D]*?DEVEL\-\->/g, "")
|
.replace(/<!\-\-DEVEL[\d\D]*?DEVEL\-\->/g, "")
|
||||||
.replace(/PACKAGE\-\->|<!\-\-PACKAGE/g, "")
|
.replace(/PACKAGE\-\->|<!\-\-PACKAGE/g, "")
|
||||||
|
|
@ -179,10 +180,14 @@ function demo() {
|
||||||
.replace("%version%", version)
|
.replace("%version%", version)
|
||||||
.replace("%commit%", ref)
|
.replace("%commit%", ref)
|
||||||
);
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
function fixDocPaths(data) {
|
||||||
|
return data.replace(/"(demo|build)\//g, "\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
copy({
|
copy({
|
||||||
source: "kitchen-sink.html",
|
source: ACE_HOME + "/kitchen-sink.html",
|
||||||
dest: BUILD_DIR + "/kitchen-sink.html",
|
dest: BUILD_DIR + "/kitchen-sink.html",
|
||||||
filter: [changeComments, function(data) {
|
filter: [changeComments, function(data) {
|
||||||
return data.replace(/"(demo|build)\//g, "\"");
|
return data.replace(/"(demo|build)\//g, "\"");
|
||||||
|
|
@ -190,30 +195,28 @@ function demo() {
|
||||||
});
|
});
|
||||||
|
|
||||||
copy({
|
copy({
|
||||||
source: "demo/kitchen-sink/styles.css",
|
source: ACE_HOME + "/demo/kitchen-sink/styles.css",
|
||||||
dest: BUILD_DIR + "/kitchen-sink/styles.css",
|
dest: BUILD_DIR + "/kitchen-sink/styles.css",
|
||||||
filter: [ changeComments ]
|
filter: [ changeComments ]
|
||||||
});
|
});
|
||||||
|
|
||||||
fs.readdirSync("demo/kitchen-sink/docs/").forEach(function(x) {
|
fs.readdirSync(ACE_HOME +"/demo/kitchen-sink/docs/").forEach(function(x) {
|
||||||
copy({
|
copy({
|
||||||
source: "demo/kitchen-sink/docs/" + x,
|
source: ACE_HOME +"/demo/kitchen-sink/docs/" + x,
|
||||||
dest: BUILD_DIR + "/kitchen-sink/docs/" + x
|
dest: BUILD_DIR + "/kitchen-sink/docs/" + x
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
var demo = copy.createDataObject();
|
var demo = copy.createDataObject();
|
||||||
copy({
|
copy({
|
||||||
source: "demo/kitchen-sink/demo.js",
|
source: ACE_HOME + "/demo/kitchen-sink/demo.js",
|
||||||
dest: demo,
|
dest: demo,
|
||||||
filter: [changeComments, function(data) {
|
filter: [changeComments, fixDocPaths, function(data) {
|
||||||
return data.replace(/"(demo|build)\//g, "\"");
|
|
||||||
}, function(data) {
|
|
||||||
return data.replace("define(", "define('kitchen-sink/demo',");
|
return data.replace("define(", "define('kitchen-sink/demo',");
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
copy({
|
copy({
|
||||||
source: "lib/ace/split.js",
|
source: ACE_HOME + "/lib/ace/split.js",
|
||||||
dest: demo,
|
dest: demo,
|
||||||
filter: [changeComments, function(data) {
|
filter: [changeComments, function(data) {
|
||||||
return data.replace("define(", "define('ace/split',");
|
return data.replace("define(", "define('ace/split',");
|
||||||
|
|
@ -224,7 +227,7 @@ function demo() {
|
||||||
dest: BUILD_DIR + "/kitchen-sink/demo.js",
|
dest: BUILD_DIR + "/kitchen-sink/demo.js",
|
||||||
});
|
});
|
||||||
|
|
||||||
copyFileSync("demo/kitchen-sink/logo.png", BUILD_DIR + "/kitchen-sink/logo.png");
|
copyFileSync(ACE_HOME + "/demo/kitchen-sink/logo.png", BUILD_DIR + "/kitchen-sink/logo.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildAce(options) {
|
function buildAce(options) {
|
||||||
|
|
@ -233,6 +236,14 @@ function buildAce(options) {
|
||||||
textPluginPattern: /^ace\/requirejs\/text!/
|
textPluginPattern: /^ace\/requirejs\/text!/
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var modeNames = fs.readdirSync(ACE_HOME + "/lib/ace/mode").map(function(x) {
|
||||||
|
if (x.slice(-3) == ".js" && !/_highlight_rules|_test|_worker|xml_util|_outdent|behaviour/.test(x))
|
||||||
|
return x.slice(0, -3);
|
||||||
|
}).filter(function(x) { return !!x; });
|
||||||
|
var themeNames = fs.readdirSync(ACE_HOME + "/lib/ace/theme").map(function(x){
|
||||||
|
return x.slice(-3) == ".js" && x.slice(0, -3);
|
||||||
|
}).filter(function(x){ return !!x; });
|
||||||
|
|
||||||
var defaults = {
|
var defaults = {
|
||||||
targetDir: BUILD_DIR + "/src",
|
targetDir: BUILD_DIR + "/src",
|
||||||
ns: "ace",
|
ns: "ace",
|
||||||
|
|
@ -242,13 +253,8 @@ function buildAce(options) {
|
||||||
noconflict: false,
|
noconflict: false,
|
||||||
suffix: null,
|
suffix: null,
|
||||||
name: "ace",
|
name: "ace",
|
||||||
modes: fs.readdirSync("lib/ace/mode").map(function(x) {
|
modes: modeNames,
|
||||||
if (x.slice(-3) == ".js" && !/_highlight_rules|_test|_worker|xml_util|_outdent|behaviour/.test(x))
|
themes: themeNames,
|
||||||
return x.slice(0, -3);
|
|
||||||
}).filter(function(x){return !!x}),
|
|
||||||
themes: fs.readdirSync("lib/ace/theme").map(function(x){
|
|
||||||
return x.slice(-3) == ".js" && x.slice(0, -3)
|
|
||||||
}).filter(function(x){return !!x}),
|
|
||||||
workers: ["javascript", "coffee", "css", "json", "xquery"],
|
workers: ["javascript", "coffee", "css", "json", "xquery"],
|
||||||
keybindings: ["vim", "emacs"]
|
keybindings: ["vim", "emacs"]
|
||||||
};
|
};
|
||||||
|
|
@ -271,7 +277,6 @@ function buildAce(options) {
|
||||||
|
|
||||||
var filters = [
|
var filters = [
|
||||||
copy.filter.moduleDefines,
|
copy.filter.moduleDefines,
|
||||||
filterTextPlugin,
|
|
||||||
removeUseStrict,
|
removeUseStrict,
|
||||||
removeLicenceCmments
|
removeLicenceCmments
|
||||||
];
|
];
|
||||||
|
|
@ -293,7 +298,7 @@ function buildAce(options) {
|
||||||
var project = copy.createCommonJsProject(aceProject);
|
var project = copy.createCommonJsProject(aceProject);
|
||||||
var ace = copy.createDataObject();
|
var ace = copy.createDataObject();
|
||||||
copy({
|
copy({
|
||||||
source: ["build_support/mini_require.js"],
|
source: [ACE_HOME + "/build_support/mini_require.js"],
|
||||||
dest: ace
|
dest: ace
|
||||||
});
|
});
|
||||||
copy({
|
copy({
|
||||||
|
|
@ -340,7 +345,7 @@ function buildAce(options) {
|
||||||
dest: targetDir + "/theme-" + theme + ".js"
|
dest: targetDir + "/theme-" + theme + ".js"
|
||||||
});*/
|
});*/
|
||||||
// use this instead, to not create separate modules for js and css
|
// use this instead, to not create separate modules for js and css
|
||||||
var themePath = "lib/ace/theme/" + theme
|
var themePath = ACE_HOME + "/lib/ace/theme/" + theme
|
||||||
var js = fs.readFileSync(themePath + ".js", "utf8");
|
var js = fs.readFileSync(themePath + ".js", "utf8");
|
||||||
js = js.replace("define(", "define('ace/theme/" + theme + "', ['require', 'exports', 'module', 'ace/lib/dom'], ");
|
js = js.replace("define(", "define('ace/theme/" + theme + "', ['require', 'exports', 'module', 'ace/lib/dom'], ");
|
||||||
|
|
||||||
|
|
@ -372,7 +377,6 @@ function buildAce(options) {
|
||||||
|
|
||||||
filters = [
|
filters = [
|
||||||
copy.filter.moduleDefines,
|
copy.filter.moduleDefines,
|
||||||
filterTextPlugin,
|
|
||||||
removeUseStrict,
|
removeUseStrict,
|
||||||
removeLicenceCmments
|
removeLicenceCmments
|
||||||
];
|
];
|
||||||
|
|
@ -427,6 +431,22 @@ function cloneProject(project) {
|
||||||
|
|
||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
copy.filter.addDefines = function(input, source) {
|
||||||
|
if (!source)
|
||||||
|
throw new Error('Missing filename for moduleDefines');
|
||||||
|
|
||||||
|
if (typeof input !== 'string')
|
||||||
|
input = input.toString();
|
||||||
|
|
||||||
|
var module = source.isLocation ? source.path : source;
|
||||||
|
|
||||||
|
input = input.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
|
||||||
|
input = '"' + input.replace(/\n/g, '\\n\\\n') + '"';
|
||||||
|
|
||||||
|
return 'define("ace/requirejs/text!' + module + '", [], ' + input + ');\n\n';
|
||||||
|
};
|
||||||
|
|
||||||
function copyFileSync(srcFile, destFile) {
|
function copyFileSync(srcFile, destFile) {
|
||||||
var BUF_LENGTH = 64*1024,
|
var BUF_LENGTH = 64*1024,
|
||||||
buf = new Buffer(BUF_LENGTH),
|
buf = new Buffer(BUF_LENGTH),
|
||||||
|
|
@ -453,16 +473,12 @@ function quoteString(str) {
|
||||||
return '"' + str.replace(/\\/, "\\\\").replace(/"/g, '\\"').replace(/\n/g, "\\\n") + '"';
|
return '"' + str.replace(/\\/, "\\\\").replace(/"/g, '\\"').replace(/\n/g, "\\\n") + '"';
|
||||||
}
|
}
|
||||||
|
|
||||||
function filterTextPlugin(text) {
|
|
||||||
return text.replace(/(['"])ace\/requirejs\/text\!/g, "$1text!");
|
|
||||||
}
|
|
||||||
|
|
||||||
function removeUseStrict(text) {
|
function removeUseStrict(text) {
|
||||||
return text.replace(/['"]use strict['"];/g, "");
|
return text.replace(/['"]use strict['"];/g, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeLicenceCmments(text) {
|
function removeLicenceCmments(text) {
|
||||||
return text.replace(/(;)\s*\/\*[\d\D]*?\*\//g, "$1");
|
return text.replace(/(;)\s*\/\*[\d\D]*?\*\//g, "$1").replace(/\n\/\/ vim.*\n(\/\/.*\n)+/g, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
function namespace(ns) {
|
function namespace(ns) {
|
||||||
|
|
|
||||||
2
build
2
build
|
|
@ -1 +1 @@
|
||||||
Subproject commit 8f508c64856878dc43cb9d0aeb028ca34ede6f5c
|
Subproject commit b5354412bfeb461b7d8020423562451a81da2c85
|
||||||
|
|
@ -49,6 +49,26 @@ var global = (function() {
|
||||||
return this;
|
return this;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
// take care of the case when requirejs is used and we just need to patch it a little bit
|
||||||
|
if (!ACE_NAMESPACE && typeof requirejs !== "undefined") {
|
||||||
|
|
||||||
|
var define = global.define;
|
||||||
|
global.define = function(id, deps, callback) {
|
||||||
|
if (typeof callback !== "function")
|
||||||
|
return define.apply(this, arguments);
|
||||||
|
|
||||||
|
return define(id, deps, function(require, exports, module) {
|
||||||
|
if (deps[2] == "module")
|
||||||
|
module.packaged = true;
|
||||||
|
return callback.apply(this, arguments);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
global.define.packaged = true;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
var _define = function(module, deps, payload) {
|
var _define = function(module, deps, payload) {
|
||||||
if (typeof module !== 'string') {
|
if (typeof module !== 'string') {
|
||||||
if (_define.original)
|
if (_define.original)
|
||||||
|
|
@ -160,29 +180,9 @@ var lookup = function(parentId, moduleName) {
|
||||||
};
|
};
|
||||||
|
|
||||||
function exportAce(ns) {
|
function exportAce(ns) {
|
||||||
|
|
||||||
if (typeof requirejs !== "undefined") {
|
|
||||||
|
|
||||||
var define = global.define;
|
|
||||||
global.define = function(id, deps, callback) {
|
|
||||||
if (typeof callback !== "function")
|
|
||||||
return define.apply(this, arguments);
|
|
||||||
|
|
||||||
return define(id, deps, function(require, exports, module) {
|
|
||||||
if (deps[2] == "module")
|
|
||||||
module.packaged = true;
|
|
||||||
return callback.apply(this, arguments);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
global.define.packaged = true;
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var require = function(module, callback) {
|
var require = function(module, callback) {
|
||||||
return _require("", module, callback);
|
return _require("", module, callback);
|
||||||
};
|
};
|
||||||
require.packaged = true;
|
|
||||||
|
|
||||||
var root = global;
|
var root = global;
|
||||||
if (ns) {
|
if (ns) {
|
||||||
|
|
@ -191,17 +191,26 @@ function exportAce(ns) {
|
||||||
root = global[ns];
|
root = global[ns];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (root.define)
|
if (!root.define || !root.define.packaged) {
|
||||||
_define.original = root.define;
|
_define.original = root.define;
|
||||||
|
|
||||||
root.define = _define;
|
root.define = _define;
|
||||||
|
root.define.packaged = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (root.require)
|
if (!root.require || !root.require.packaged) {
|
||||||
_require.original = root.require;
|
_require.original = root.require;
|
||||||
|
|
||||||
root.require = require;
|
root.require = require;
|
||||||
|
root.require.packaged = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
exportAce(ACE_NAMESPACE);
|
exportAce(ACE_NAMESPACE);
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
define('ace/requirejs/text', ['require', 'exports', 'module'], function(require, exports, module) {
|
||||||
|
// this won't be called it is needed only for included text modules
|
||||||
|
exports.load = function (name, req, onLoad, config) {
|
||||||
|
require("ace/lib/net").get(req.toUrl(name), onLoad);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
|
||||||
13
install.js
13
install.js
|
|
@ -39,22 +39,11 @@
|
||||||
|
|
||||||
var buildAce = require("./Makefile.dryice").buildAce;
|
var buildAce = require("./Makefile.dryice").buildAce;
|
||||||
|
|
||||||
|
|
||||||
var ACE_HOME = __dirname;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var aceProject = {
|
buildAce({
|
||||||
roots: [
|
|
||||||
ACE_HOME + '/lib',
|
|
||||||
ACE_HOME + '/demo'
|
|
||||||
],
|
|
||||||
textPluginPattern: /^ace\/requirejs\/text!/
|
|
||||||
};
|
|
||||||
buildAce(aceProject, {
|
|
||||||
compress: false,
|
compress: false,
|
||||||
noconflict: false,
|
noconflict: false,
|
||||||
suffix: "",
|
suffix: "",
|
||||||
compat: true,
|
|
||||||
name: "ace"
|
name: "ace"
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue