simplify require used in worker

This commit is contained in:
nightwing 2013-04-30 01:30:17 +04:00
commit ea31c9fac6
2 changed files with 10 additions and 9 deletions

View file

@ -417,9 +417,7 @@ var buildAce = function(options) {
source: [{
project: workerProject,
require: [
'ace/lib/fixoldbrowsers',
'ace/lib/event_emitter',
'ace/lib/oop',
'ace/worker/worker',
'ace/mode/' + mode + '_worker'
]
}],
@ -428,7 +426,6 @@ var buildAce = function(options) {
});
copy({
source: [
ACE_HOME + "/lib/ace/worker/worker.js",
worker
],
filter: options.compress ? [copy.filter.uglifyjs] : [],

View file

@ -38,6 +38,10 @@ window.normalizeModule = function(parentId, moduleName) {
};
window.require = function(parentId, id) {
if (!id) {
id = parentId
parentId = null;
}
if (!id.charAt)
throw new Error("worker.js require() accepts only (parentId, id) as arguments");
@ -58,7 +62,7 @@ window.require = function(parentId, id) {
require.id = id;
importScripts(path);
return require(parentId, id);
return require(parentId, id);
};
require.modules = {};
@ -102,8 +106,8 @@ window.initBaseUrls = function initBaseUrls(topLevelNamespaces) {
window.initSender = function initSender() {
var EventEmitter = require(null, "ace/lib/event_emitter").EventEmitter;
var oop = require(null, "ace/lib/oop");
var EventEmitter = require("ace/lib/event_emitter").EventEmitter;
var oop = require("ace/lib/oop");
var Sender = function() {};
@ -145,9 +149,9 @@ window.onmessage = function(e) {
}
else if (msg.init) {
initBaseUrls(msg.tlns);
require(null, "ace/lib/fixoldbrowsers");
require("ace/lib/es5-shim");
sender = initSender();
var clazz = require(null, msg.module)[msg.classname];
var clazz = require(msg.module)[msg.classname];
main = new clazz(sender);
}
else if (msg.event && sender) {