simplify require used in worker
This commit is contained in:
parent
23f9f6f849
commit
ea31c9fac6
2 changed files with 10 additions and 9 deletions
|
|
@ -417,9 +417,7 @@ var buildAce = function(options) {
|
||||||
source: [{
|
source: [{
|
||||||
project: workerProject,
|
project: workerProject,
|
||||||
require: [
|
require: [
|
||||||
'ace/lib/fixoldbrowsers',
|
'ace/worker/worker',
|
||||||
'ace/lib/event_emitter',
|
|
||||||
'ace/lib/oop',
|
|
||||||
'ace/mode/' + mode + '_worker'
|
'ace/mode/' + mode + '_worker'
|
||||||
]
|
]
|
||||||
}],
|
}],
|
||||||
|
|
@ -428,7 +426,6 @@ var buildAce = function(options) {
|
||||||
});
|
});
|
||||||
copy({
|
copy({
|
||||||
source: [
|
source: [
|
||||||
ACE_HOME + "/lib/ace/worker/worker.js",
|
|
||||||
worker
|
worker
|
||||||
],
|
],
|
||||||
filter: options.compress ? [copy.filter.uglifyjs] : [],
|
filter: options.compress ? [copy.filter.uglifyjs] : [],
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,10 @@ window.normalizeModule = function(parentId, moduleName) {
|
||||||
};
|
};
|
||||||
|
|
||||||
window.require = function(parentId, id) {
|
window.require = function(parentId, id) {
|
||||||
|
if (!id) {
|
||||||
|
id = parentId
|
||||||
|
parentId = null;
|
||||||
|
}
|
||||||
if (!id.charAt)
|
if (!id.charAt)
|
||||||
throw new Error("worker.js require() accepts only (parentId, id) as arguments");
|
throw new Error("worker.js require() accepts only (parentId, id) as arguments");
|
||||||
|
|
||||||
|
|
@ -58,7 +62,7 @@ window.require = function(parentId, id) {
|
||||||
|
|
||||||
require.id = id;
|
require.id = id;
|
||||||
importScripts(path);
|
importScripts(path);
|
||||||
return require(parentId, id);
|
return require(parentId, id);
|
||||||
};
|
};
|
||||||
|
|
||||||
require.modules = {};
|
require.modules = {};
|
||||||
|
|
@ -102,8 +106,8 @@ window.initBaseUrls = function initBaseUrls(topLevelNamespaces) {
|
||||||
|
|
||||||
window.initSender = function initSender() {
|
window.initSender = function initSender() {
|
||||||
|
|
||||||
var EventEmitter = require(null, "ace/lib/event_emitter").EventEmitter;
|
var EventEmitter = require("ace/lib/event_emitter").EventEmitter;
|
||||||
var oop = require(null, "ace/lib/oop");
|
var oop = require("ace/lib/oop");
|
||||||
|
|
||||||
var Sender = function() {};
|
var Sender = function() {};
|
||||||
|
|
||||||
|
|
@ -145,9 +149,9 @@ window.onmessage = function(e) {
|
||||||
}
|
}
|
||||||
else if (msg.init) {
|
else if (msg.init) {
|
||||||
initBaseUrls(msg.tlns);
|
initBaseUrls(msg.tlns);
|
||||||
require(null, "ace/lib/fixoldbrowsers");
|
require("ace/lib/es5-shim");
|
||||||
sender = initSender();
|
sender = initSender();
|
||||||
var clazz = require(null, msg.module)[msg.classname];
|
var clazz = require(msg.module)[msg.classname];
|
||||||
main = new clazz(sender);
|
main = new clazz(sender);
|
||||||
}
|
}
|
||||||
else if (msg.event && sender) {
|
else if (msg.event && sender) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue