diff --git a/Makefile.dryice.js b/Makefile.dryice.js index faf2b08a0aa..b06a5252ad1 100755 --- a/Makefile.dryice.js +++ b/Makefile.dryice.js @@ -346,7 +346,7 @@ function buildAceModuleInternal(opts, callback) { ignore: opts.ignore || [], withRequire: false, basepath: ACE_HOME, - transforms: [normalizeLineEndings], + transforms: [normalizeLineEndings, includeLoader], afterRead: [optimizeTextModules] }, write); } @@ -358,7 +358,7 @@ function buildCore(options, extra, callback) { order: -1000, literal: true }]; - options.require =["ace/ace"]; + options.require =["ace/ace", "ace/loader_build"]; options.projectType = "main"; options.ns = "ace"; buildAceModule(options, callback); @@ -583,6 +583,17 @@ function normalizeLineEndings(module) { return module.source = module.source.replace(/\r\n/g, "\n"); } +function includeLoader(module) { + var pattern = '"include loader_build";'; + if (module.source && module.source.indexOf(pattern) != -1) { + console.log("===================================== ====================================="); + console.log(module); + console.log("===================================== ====================================="); + module.deps.push("ace/loader_build"); + module.source = module.source.replace(pattern, 'require("./loader_build")(exports)'); + } +} + function optimizeTextModules(sources) { var textModules = {}; return sources.filter(function(pkg) { diff --git a/demo/kitchen-sink/demo.js b/demo/kitchen-sink/demo.js index fc88fbf9e8a..92cd52fe4c9 100644 --- a/demo/kitchen-sink/demo.js +++ b/demo/kitchen-sink/demo.js @@ -32,8 +32,6 @@ define(function(require, exports, module) { "use strict"; -require("ace/lib/fixoldbrowsers"); - require("ace/ext/rtl"); require("ace/multi_select"); diff --git a/lib/ace/ace.js b/lib/ace/ace.js index be2be04b63e..b17fc1c46f7 100644 --- a/lib/ace/ace.js +++ b/lib/ace/ace.js @@ -36,8 +36,7 @@ define(function(require, exports, module) { "use strict"; - -require("./lib/fixoldbrowsers"); +"include loader_build"; var dom = require("./lib/dom"); var event = require("./lib/event"); @@ -59,15 +58,6 @@ require("./ext/error_marker"); exports.config = require("./config"); -/** - * Provides access to require in packed noconflict mode - * @param {String} moduleName - * @returns {Object} - **/ -exports.require = require; - -if (typeof define === "function") - exports.define = define; /** * Embeds the Ace editor into the DOM, at the element provided by `el`. diff --git a/lib/ace/config.js b/lib/ace/config.js index c500bf51862..be175c9ae1f 100644 --- a/lib/ace/config.js +++ b/lib/ace/config.js @@ -39,10 +39,6 @@ var AppConfig = require("./lib/app_config").AppConfig; module.exports = exports = new AppConfig(); -var global = (function() { - return this || typeof window != "undefined" && window; -})(); - var options = { packaged: false, workerPath: null, @@ -113,12 +109,12 @@ exports.setModuleUrl = function(name, subst) { var loader = function(moduleName, cb) { if (moduleName == "ace/theme/textmate") return cb(null, require("./theme/textmate")); - return console.error("loader is not configured") -} + return console.error("loader is not configured"); +}; exports.setLoader = function(cb) { - loader = cb -} + loader = cb; +}; exports.$loading = {}; exports.loadModule = function(moduleName, onLoad) { @@ -176,63 +172,6 @@ var reportErrorIfPathIsNotConfigured = function() { } }; -// initialization -function init(packaged) { - if (!global || !global.document) - return; - - options.packaged = packaged || require.packaged || module.packaged || (global.define && define.packaged); - - var scriptOptions = {}; - var scriptUrl = ""; - - // Use currentScript.ownerDocument in case this file was loaded from imported document. (HTML Imports) - var currentScript = (document.currentScript || document._currentScript ); // native or polyfill - var currentDocument = currentScript && currentScript.ownerDocument || document; - - var scripts = currentDocument.getElementsByTagName("script"); - for (var i=0; i