Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use mini require #4845

Merged
merged 2 commits into from
Jul 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions Makefile.dryice.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ function buildAceModuleInternal(opts, callback) {
ignore: opts.ignore || [],
withRequire: false,
basepath: ACE_HOME,
transforms: [normalizeLineEndings],
transforms: [normalizeLineEndings, includeLoader],
afterRead: [optimizeTextModules]
}, write);
}
Expand All @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down
9 changes: 6 additions & 3 deletions demo/kitchen-sink/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
define(function(require, exports, module) {
"use strict";

require("ace/lib/fixoldbrowsers");

require("ace/ext/rtl");

require("ace/multi_select");
Expand All @@ -42,7 +40,12 @@ var devUtil = require("./dev_util");
require("./file_drop");

var config = require("ace/config");
config.init();
config.setLoader(function(moduleName, cb) {
require([moduleName], function(module) {
cb(null, module)
})
});

var env = {};

var dom = require("ace/lib/dom");
Expand Down
3 changes: 2 additions & 1 deletion demo/kitchen-sink/dev_util.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
* ***** END LICENSE BLOCK ***** */

define(function(require, exports, module) {
var ace = require("ace/ace");
var dom = require("ace/lib/dom");
var event = require("ace/lib/event");
var Range = require("ace/range").Range;
Expand All @@ -48,7 +49,7 @@ function def(o, key, get) {
console.error(e);
}
}
def(window, "ace", function(){ return window.env.editor });
def(window, "ace", function(){ return ace });
def(window, "editor", function(){ return window.env.editor == logEditor ? editor : window.env.editor });
def(window, "session", function(){ return window.editor.session });
def(window, "split", function(){ return window.env.split });
Expand Down
Loading