Fixed: Asynchronous and output changes from the new Terser compressor

This commit is contained in:
Martin Carlberg committed 2021-09-21 11:09:09 +02:00
1 parent 6b1cdbd19c
commit d70199ca58
5 files changed
+12 -11

No files matched your search

@@ -4,8 +4,8 @@ class_addMethods(the_class,[new objj_method(sel_getUid("mySelector"),function $M
(_1.isa.method_msgSend["init"]||_objj_forward)(_1,"init");
_1=nil;
(_1==null?_1:(_1.isa.method_msgSend["init"]||_objj_forward)(_1,"init"));
},["id"]),new objj_method(sel_getUid("mySelector2"),function $MyClass__mySelector2(_3,_4){
(_3.isa.method_msgSend["init"]||_objj_forward)(_3,"init");
},["id"]),new objj_method(sel_getUid("mySelector2"),function $MyClass__mySelector2(self,_cmd){
(self.isa.method_msgSend["init"]||_objj_forward)(self,"init");
eval("self = null;");
(_3==null?_3:(_3.isa.method_msgSend["init"]||_objj_forward)(_3,"init"));
(self==null?self:(self.isa.method_msgSend["init"]||_objj_forward)(self,"init"));
},["id"])]);
@@ -4,8 +4,8 @@ class_addMethods(the_class,[new objj_method(sel_getUid("mySelector"),function $M
_1.isa.objj_msgSend0(_1,"init");
_1=nil;
(_1==null?_1:_1.isa.objj_msgSend0(_1,"init"));
},["id"]),new objj_method(sel_getUid("mySelector2"),function $MyClass__mySelector2(_3,_4){
_3.isa.objj_msgSend0(_3,"init");
},["id"]),new objj_method(sel_getUid("mySelector2"),function $MyClass__mySelector2(self,_cmd){
self.isa.objj_msgSend0(self,"init");
eval("self = null;");
(_3==null?_3:_3.isa.objj_msgSend0(_3,"init"));
(self==null?self:self.isa.objj_msgSend0(self,"init"));
},["id"])]);
@@ -5,7 +5,7 @@
- (id)a
{
@ref(_control);
var x = @ref(_control);
}
@end
@@ -2,7 +2,7 @@
meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_control","id")]);objj_registerClassPair(the_class);
class_addMethods(the_class, [new objj_method(sel_getUid("a"), function $TC__a(self, _cmd)
{
function(__input) { if (arguments.length) return self._control = __input; return self._control; };
var x = function(__input) { if (arguments.length) return self._control = __input; return self._control; };
}
,["id"])]);
@@ -32,7 +32,8 @@ var FILENAMES = [
}
async function compressor(srcCode) {
return (await terser.minify(srcCode)).code;
var m = await terser.minify(srcCode, { keep_fnames: false, mangle: { properties: true }, toplevel: true });
return m.code;
}
+ (void)initialize
@@ -59,12 +60,12 @@ async function compressor(srcCode) {
correctInlined = fs.existsSync(p) ? fs.readFileSync(p, {encoding: "utf8"}) : correct; // Get inlined version if it exists. Otherwise use the regular one.
await [self assertNoThrow: async function() {
preprocessed = ObjectiveJ.ObjJCompiler.compileToExecutable(unpreprocessed, nil, {includeMethodFunctionNames: true, includeMethodArgumentTypeSignatures: true, includeIvarTypeSignatures: true, inlineMsgSendFunctions: false, transformNamedFunctionDeclarationToAssignment: true}).code();
preprocessed = ObjectiveJ.ObjJCompiler.compile(unpreprocessed, nil, {includeMethodFunctionNames: true, includeMethodArgumentTypeSignatures: true, includeIvarTypeSignatures: true, inlineMsgSendFunctions: false, transformNamedFunctionDeclarationToAssignment: true}).jsBuffer.toString();
preprocessed = await compressor(preprocessed);
correct = await compressor(correct);
// Get an Inlined version
preprocessedInlined = ObjectiveJ.ObjJCompiler.compileToExecutable(unpreprocessed, nil, {includeMethodFunctionNames: true, includeMethodArgumentTypeSignatures: true, includeIvarTypeSignatures: true, inlineMsgSendFunctions: true, transformNamedFunctionDeclarationToAssignment:true}).code();
preprocessedInlined = ObjectiveJ.ObjJCompiler.compile(unpreprocessed, nil, {includeMethodFunctionNames: true, includeMethodArgumentTypeSignatures: true, includeIvarTypeSignatures: true, inlineMsgSendFunctions: true, transformNamedFunctionDeclarationToAssignment: true}).jsBuffer.toString();
preprocessedInlined = await compressor(preprocessedInlined);
correctInlined = await compressor(correctInlined);
}];