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
Fix jsx error #252
Fix jsx error #252
Conversation
EDIT: This has been resolved, leaving it here for archival purposes. The size difference is coming from Source: async function foo(...args) {
return [await two(...args), await two(...args)];
}
async function two(...args) {
return args.reduce((total, value) => total + value, 0);
}
foo(); master (via nodent): function n() {
for (var n = [], r = arguments.length; r--; ) n[r] = arguments[r];
return new Promise(function(r, t) {
return r(
n.reduce(function(n, r) {
return n + r;
}, 0),
);
});
}
module.exports = function() {
for (var r = [], t = arguments.length; t--; ) r[t] = arguments[t];
return new Promise(function(t, e) {
return n.apply(void 0, r).then(function(u) {
try {
return n.apply(void 0, r).then(function(n) {
try {
return t([u, n]);
} catch (n) {
return e(n);
}
}, e);
} catch (n) {
return e(n);
}
}, e);
});
}; Output from this PR: const _async = (function() {
try {
if (isNaN.apply(null, {})) {
return function(f) {
return function() {
try {
return Promise.resolve(f.apply(this, arguments));
} catch (e) {
return Promise.reject(e);
}
};
};
}
} catch (e) {}
return function(f) {
// Pre-ES5.1 JavaScript runtimes don't accept array-likes in Function.apply
return function() {
var args = [];
for (var i = 0; i < arguments.length; i++) {
args[i] = arguments[i];
}
try {
return Promise.resolve(f.apply(this, args));
} catch (e) {
return Promise.reject(e);
}
};
};
})();
function _await(value, then, direct) {
if (direct) {
return then ? then(value) : value;
}
value = Promise.resolve(value);
return then ? value.then(then) : value;
}
const two = _async(function(...args) {
return args.reduce((total, value) => total + value, 0);
});
const foo = function(...args) {
return _await(two(...args), function(_two) {
return _await(two(...args), function(_two2) {
return [_two, _two2];
});
});
};
foo(); |
29bb9f6
to
bdc8698
Compare
@ForsakenHarmony can you retry the build? I can't reproduce the linting error that failed it locally |
|
69b55f0
to
271a030
Compare
Co-Authored-By: marvinhagemeister <marvin@marvinhagemeister.de>
271a030
to
a89d6d2
Compare
@ForsakenHarmony All the review comments have been addressed and I squashed the commits. I think the PR is ready for another review 👍 |
@wardpeet Point 3) seems like the best choice for me. We didn't support custom babel configs before, so we should be ok to disable it. |
sweet didn't knew that so if we just put |
@wardpeet Added that line to the babel plugin. We weren't supporting this earlier because we didn't had babel included in the first place :) |
@marvinhagemeister works like a charm now! |
da873a5
to
bd6b552
Compare
Still wondering how fast-async would compare (it would not have the same problem, because jsx is handled elsewhere in babel) |
Did a few comparisons agaist Where Used the example benchmark code that is linked here, a few microbundle test cases and some of my own code. |
Guessing you've tried all the options of fast async, well I can merge if you want |
That'd be awesome and I'd love if a release could be made in the following days 🎉 The jsx error is ever present on the CI for |
@ForsakenHarmony woohoo, thanks for merging 🎉👍 |
This PR changes quite a few compiler related thing to fix the nasty jsx error. The error is caused by breaking changes in the
acorn
plugin architecture. Being really complex and not maintained anymore I swapped it out in favour of a babel plugin.nodent
withbabel-plugin-transform-async-to-promises
async/await
transform)Note that the compiled file sizes got significantly larger. I still need to investigate why that's the case. Perhaps someone else can have a look at it? /cc @developit
Fixes #74