Skip to content

Commit

Permalink
simplify require used in worker
Browse files Browse the repository at this point in the history
  • Loading branch information
nightwing committed Apr 29, 2013
1 parent 23f9f6f commit ea31c9f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
5 changes: 1 addition & 4 deletions Makefile.dryice.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
]
}],
Expand All @@ -428,7 +426,6 @@ var buildAce = function(options) {
});
copy({
source: [
ACE_HOME + "/lib/ace/worker/worker.js",
worker
],
filter: options.compress ? [copy.filter.uglifyjs] : [],
Expand Down
14 changes: 9 additions & 5 deletions lib/ace/worker/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand All @@ -58,7 +62,7 @@ window.require = function(parentId, id) {

require.id = id;
importScripts(path);
return require(parentId, id);
return require(parentId, id);
};

require.modules = {};
Expand Down Expand Up @@ -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() {};

Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit ea31c9f

Please sign in to comment.