Closed naturalethic closed 8 years ago
I get this even for non-async
functions:
% cat export.js
export function test() {
return 1;
}
% babel --presets es2015 --plugins fast-async export.js
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Function.prototype.$asyncbind = <snip>;
function test() {
return 1;
}
And export default function
will error with "ReferenceError: $1 is not defined":
% babel --presets es2015 --plugins fast-async export_default.js
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Function.prototype.$asyncbind = <snip>
exports.default = $1;
function test() {
return 1;
}
Thanks for pointing this one out. Can you tell me the exact versions of fast-async, nodent and acorn-es7-plugin that was installed in your test environment, as I fixed some export-async issues recently. I'm unable to when through issues for a week as I'm away, but will get these patches when I'm back
For myself:
fast-async@6.0.31
nodent@2.6.2
acorn-es7-plugin@1.0.17
They're all latest, so it might be something I've missed. However, this might be a Babel issue, as the online compiler (same versions as you - no Babel, just nodent and acorn doing the transpiling) seems to generate good code:
http://nodent.mailed.me.uk/#export%20async%20function%20foo()%20%7B%7D
@simonbuchan's comment would seem to support the theory it's a Babel issue, but I'll take a look anyway, unless you determine this one way or the other in advance
Well they export fine without --plugins fast-async
, or with the regenerator based transform plugins, but it does look like an interaction with Babel's module transform
Having the same issues
Out of interest, what happens if you reverse the order of the plugins (ie fast-async before the presets). I'm still away so I can't test this myself for a few days!
Fixed in fast-async@6.0.32
Confirmed. Thanks!
NP :)
Will rewrite an exported function into a non-exported given for example:
export async function foo() {}
This then requires a manual export later in the file.