Skip to content

Commit 6714359

Browse files
committed
tweak
1 parent e5b2eed commit 6714359

File tree

3 files changed

+24
-40
lines changed

3 files changed

+24
-40
lines changed

Makefile

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ pre_build:
1313
build: pre_build
1414
./Makefile.dryice.js normal
1515
./Makefile.dryice.js demo
16-
./Makefile.dryice.js bm
1716

1817
# Minimal build: call Makefile.dryice.js only if our sources changed
1918
basic: build/src/ace.js

Makefile.dryice.js

+23-38
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,11 @@ function ace() {
112112
function demo() {
113113
console.log('# kitchen sink ---------');
114114

115-
var version, ref;
115+
var version = "", ref = "";
116116
try {
117117
version = JSON.parse(fs.readFileSync(ACE_HOME + "/package.json")).version;
118118
ref = fs.readFileSync(ACE_HOME + "/.git-ref").toString();
119-
} catch(e) {
120-
ref = "";
121-
version = "";
122-
}
119+
} catch(e) {}
123120

124121
function changeComments(data) {
125122
return (data
@@ -131,16 +128,12 @@ function demo() {
131128
.replace("%commit%", ref)
132129
);
133130
}
134-
135-
copy(ACE_HOME + "/demo/kitchen-sink", BUILD_DIR + "/demo/kitchen-sink", {
136-
shallow: true,
137-
replace: [changeComments],
138-
include: /\.(css|html)$/
139-
});
140131

141132
copy(ACE_HOME +"/demo/kitchen-sink/docs/", BUILD_DIR + "/demo/kitchen-sink/docs/");
142133

143134
copy.file(ACE_HOME + "/demo/kitchen-sink/logo.png", BUILD_DIR + "/demo/kitchen-sink/logo.png");
135+
copy.file(ACE_HOME + "/demo/kitchen-sink/styles.css", BUILD_DIR + "/demo/kitchen-sink/styles.css");
136+
copy.file(ACE_HOME + "/kitchen-sink.html", BUILD_DIR + "/kitchen-sink.html", changeComments);
144137

145138
buildSubmodule({}, {
146139
require: ["kitchen-sink/demo"],
@@ -214,9 +207,9 @@ function buildAceModule(opts, callback) {
214207
buildAceModule.dequeue = function() {
215208
if (buildAceModule.running) return;
216209
var call = buildAceModule.queue.shift();
210+
buildAceModule.running = call;
217211
if (call)
218212
buildAceModuleInternal.apply(null, call);
219-
buildAceModule.running = call;
220213
};
221214
}
222215

@@ -235,7 +228,7 @@ function buildAceModule(opts, callback) {
235228

236229
function buildAceModuleInternal(opts, callback) {
237230
var cache = opts.cache == undefined ? CACHE : opts.cache;
238-
var key = opts.require + "|" + opts.compress + "|" + opts.projectType;
231+
var key = opts.require + "|" + opts.projectType;
239232
if (cache && cache.configs && cache.configs[key])
240233
return write(null, cache.configs[key]);
241234

@@ -249,19 +242,23 @@ function buildAceModuleInternal(opts, callback) {
249242
};
250243

251244
function write(err, result) {
252-
if (opts.compress)
253-
result.code = compress(result.code);
254-
255-
if (cache && key) {
245+
if (cache && key && !(cache.configs && cache.configs[key])) {
256246
cache.configs = cache.configs || Object.create(null);
257247
cache.configs[key] = result;
258248
result.sources = result.sources.map(function(pkg) {
259249
return {deps: pkg.deps};
260250
});
261-
}
251+
}
262252

263253
if (!opts.outputFile)
264254
return callback(err, result);
255+
256+
var code = result.code;
257+
if (opts.compress) {
258+
if (!result.codeMin)
259+
result.codeMin = compress(result.code);
260+
code = result.codeMin;
261+
}
265262

266263
var targetDir = BUILD_DIR + "/src";
267264
if (opts.compress)
@@ -287,7 +284,6 @@ function buildAceModuleInternal(opts, callback) {
287284
opts.noconflict ? ns : "", projectType == "ext"));
288285
}
289286

290-
var code = result.code;
291287
filters.forEach(function(f) { code = f(code); });
292288

293289
build.writeToFile({code: code}, {
@@ -331,7 +327,7 @@ function buildSubmodule(options, extra, file, callback) {
331327
options = extend(extra, options);
332328
getLoadedFileList(options, function(coreFiles) {
333329
options.outputFile = file + ".js";
334-
options.ignore = coreFiles;
330+
options.ignore = options.ignore || coreFiles;
335331
options.quiet = true;
336332
buildAceModule(options, callback);
337333
});
@@ -384,9 +380,10 @@ function buildAce(options) {
384380
buildSubmodule(options, {
385381
projectType: "worker",
386382
require: ["ace/mode/" + name + "_worker"],
383+
ignore: [],
387384
additional: [{
388385
id: "ace/worker/worker",
389-
loaderModule: true,
386+
transforms: [],
390387
order: -1000
391388
}],
392389
}, "worker-" + name);
@@ -467,9 +464,7 @@ function namespace(ns) {
467464
return function(text) {
468465
text = text
469466
.toString()
470-
.replace('var ACE_NAMESPACE = "";', 'var ACE_NAMESPACE = "' + ns +'";')
471-
// .replace(/(\.define)|([,;\n]|^\s*?)define\(/g, function(_, a, b) {
472-
// return a || b + ns + ".define(";
467+
.replace(/ACE_NAMESPACE\s*=\s*""/, 'ACE_NAMESPACE = "' + ns +'"')
473468
.replace(/(\.define)|\bdefine\(/g, function(_, a) {
474469
return a || ns + ".define(";
475470
});
@@ -551,20 +546,10 @@ function addSnippetFile(modeName) {
551546
}
552547

553548
function compress(text) {
554-
return asciify(require("dryice").copy.filter.uglifyjs(text));
555-
// copy.filter.uglifyjs.options.ascii_only = true; doesn't work with some uglify.js versions
556-
function asciify(text) {
557-
return text.replace(/[\x00-\x08\x0b\x0c\x0e\x19\x80-\uffff]/g, function(c) {
558-
c = c.charCodeAt(0).toString(16);
559-
if (c.length == 1)
560-
return "\\x0" + c;
561-
if (c.length == 2)
562-
return "\\x" + c;
563-
if (c.length == 3)
564-
return "\\u0" + c;
565-
return "\\u" + c;
566-
});
567-
}
549+
var ujs = require("dryice").copy.filter.uglifyjs;
550+
ujs.options.mangle_toplevel = {except: ["ACE_NAMESPACE", "requirejs"]};
551+
ujs.options.beautify = {ascii_only: true, inline_script: true}
552+
return ujs(text);
568553
}
569554

570555
function extend(base, extra) {

kitchen-sink.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@
281281
<script src="src/ace.js" data-ace-base="src" type="text/javascript" charset="utf-8"></script>
282282
<script src="src/keybinding-vim.js"></script>
283283
<script src="src/keybinding-emacs.js"></script>
284-
<script src="kitchen-sink/demo.js"></script>
284+
<script src="demo/kitchen-sink/demo.js"></script>
285285
<script type="text/javascript" charset="utf-8">
286286
require("kitchen-sink/demo");
287287
</script>

0 commit comments

Comments
 (0)