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

Clobbers single line function definition export #7

Closed
naturalethic opened this issue Jul 26, 2016 · 11 comments
Closed

Clobbers single line function definition export #7

naturalethic opened this issue Jul 26, 2016 · 11 comments

Comments

@naturalethic
Copy link

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.

@simonbuchan
Copy link

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;
}

@MatAtBread
Copy link
Owner

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

@naturalethic
Copy link
Author

For myself:

fast-async@6.0.31
nodent@2.6.2
acorn-es7-plugin@1.0.17

@MatAtBread
Copy link
Owner

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

@MatAtBread
Copy link
Owner

@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

@simonbuchan
Copy link

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

@nightwolfz
Copy link

Having the same issues

@MatAtBread
Copy link
Owner

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!

@MatAtBread
Copy link
Owner

Fixed in fast-async@6.0.32

@naturalethic
Copy link
Author

Confirmed. Thanks!

@MatAtBread
Copy link
Owner

NP :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants