make build system worker compatible

This commit is contained in:
Fabian Jakobs 2011-01-26 17:08:34 +01:00
commit 4af6988ece
3 changed files with 105 additions and 89 deletions

View file

@ -91,11 +91,12 @@ copy({
{ {
root: aceHome + '/lib', root: aceHome + '/lib',
include: /.*\.js$/, include: /.*\.js$/,
exclude: /tests?\/|theme\/|mode\// exclude: /tests?\/|theme\/|mode\/|ace\/worker\/host\.js/
}, },
{ base: aceHome + '/lib/', path: 'ace/theme/textmate.js' }, { base: aceHome + '/lib/', path: 'ace/theme/textmate.js' },
{ base: aceHome + '/lib/', path: 'ace/mode/text.js' }, { base: aceHome + '/lib/', path: 'ace/mode/text.js' },
{ base: aceHome + '/lib/', path: 'ace/mode/javascript.js' }, { base: aceHome + '/lib/', path: 'ace/mode/javascript.js' },
{ base: aceHome + '/lib/', path: 'ace/mode/javascript_worker.js' },
{ base: aceHome + '/lib/', path: 'ace/mode/text_highlight_rules.js' }, { base: aceHome + '/lib/', path: 'ace/mode/text_highlight_rules.js' },
{ base: aceHome + '/lib/', path: 'ace/mode/javascript_highlight_rules.js' }, { base: aceHome + '/lib/', path: 'ace/mode/javascript_highlight_rules.js' },
{ base: aceHome + '/lib/', path: 'ace/mode/doc_comment_highlight_rules.js' }, { base: aceHome + '/lib/', path: 'ace/mode/doc_comment_highlight_rules.js' },
@ -121,7 +122,6 @@ copy({
source: [ source: [
'build_support/mini_require.js', 'build_support/mini_require.js',
pilot, pilot,
// cockpit,
ace, ace,
'build_support/boot.js' 'build_support/boot.js'
], ],
@ -146,7 +146,14 @@ copy({
dest: 'build/ace-uncompressed.js' dest: 'build/ace-uncompressed.js'
}); });
// Create worker bootstrap code
copy({
source: "lib/ace/worker/host.js",
filter: [function(data) {
return data + "\nimportScripts('ace-uncompressed.js')";
}],
dest: 'build/host.js'
});

View file

@ -35,6 +35,9 @@
* *
* ***** END LICENSE BLOCK ***** */ * ***** END LICENSE BLOCK ***** */
// don't define it in a worker.
if (window.document) {
var deps = [ "pilot/fixoldbrowsers", "pilot/plugin_manager", "pilot/settings", var deps = [ "pilot/fixoldbrowsers", "pilot/plugin_manager", "pilot/settings",
"pilot/environment" ]; "pilot/environment" ];
@ -73,3 +76,4 @@ var ace = {
}); });
} }
}; };
}

View file

@ -35,7 +35,10 @@
* *
* ***** END LICENSE BLOCK ***** */ * ***** END LICENSE BLOCK ***** */
function require(module, callback) { // don't define it in a worker. There we have a different implementation
if (window.document) {
window.require = function(module, callback) {
if (Array.isArray(module)) { if (Array.isArray(module)) {
var params = []; var params = [];
@ -57,6 +60,7 @@ function require(module, callback) {
} }
} }
require.modules = {}; require.modules = {};
require.packaged = true;
require._lookup = function(moduleName) { require._lookup = function(moduleName) {
var payload = require.modules[moduleName]; var payload = require.modules[moduleName];
@ -81,7 +85,7 @@ require._lookup = function(moduleName) {
return payload; return payload;
}; };
function define(module, payload) { window.define = function(module, payload) {
if (typeof module !== 'string') { if (typeof module !== 'string') {
console.error('dropping module because define wasn\'t munged.'); console.error('dropping module because define wasn\'t munged.');
console.trace(); console.trace();
@ -91,3 +95,4 @@ function define(module, payload) {
// console.log('defining module: ' + module + ' as a ' + typeof payload); // console.log('defining module: ' + module + ' as a ' + typeof payload);
require.modules[module] = payload; require.modules[module] = payload;
} }
}