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

rxjs-es build cannot be complied by Babel #1806

Closed
mitchlloyd opened this issue Jul 5, 2016 · 6 comments · Fixed by #1807
Closed

rxjs-es build cannot be complied by Babel #1806

mitchlloyd opened this issue Jul 5, 2016 · 6 comments · Fixed by #1807
Assignees

Comments

@mitchlloyd
Copy link

@Blesh As a follow up from https://twitter.com/BenLesh/status/750378713905192960, here is an issue for this workaround that I've seen in a couple of code bases.

RxJS version:

5.0.0-beta.9

Code to reproduce:

Compile rxjs source with Babel.

See existing workarounds as example:

Expected behavior:

Babel compiles rxjs-es source without errors.

Actual behavior:

Babel throws Unexpected Token error similar to this: https://babeljs.io/repl/#?evaluate=true&lineWrap=false&presets=es2015%2Creact%2Cstage-2&code=let%20Scheduler%20%3D%20%7B%0A%20%20asap%2C%0A%20%20async%2C%0A%20%20queue%2C%0A%20%20animationFrame%0A%7D%3B

@kwonoj
Copy link
Member

kwonoj commented Jul 5, 2016

Is my understanding correct that needed thing is update Scheduler object to not use enhanced object literal?

@benlesh
Copy link
Member

benlesh commented Jul 5, 2016

@mitchlloyd that looks like a problem with Babel. async might be a new keyword, but it's still a valid variable name.

For those reading this, the problem appears to be to name of the async scheduler: Scheduler.async

Babel is unable to process creating an object literal like so:

let foo = 'whatever';
let async = 'test';
let obj = {
  async,
  foo
};

Interestingly, this works:

let foo = 'whatever';
let async = 'test';
let obj = {
  foo,
  async
};

@kwonoj
Copy link
Member

kwonoj commented Jul 5, 2016

I just gave it a try bit more, and came to agree with @Blesh . If you're enabling stage-3 preset or above in babel, it fails to build. (Assume transform-async-to-generator is culprit maybe?)
https://babeljs.io/repl/#?evaluate=true&lineWrap=true&presets=es2015&code=let%20Scheduler%20%3D%20%7B%0A%20%20asap%2C%0A%20%20async%2C%0A%20%20queue%2C%0A%20%20animationFrame%0A%7D%3B

@benlesh
Copy link
Member

benlesh commented Jul 5, 2016

I have a fix inbound. Just a workaround we can do to accommodate until babel's issue is resolved.

@mitchlloyd
Copy link
Author

Awesome! Agreed that this appears to be a Babel bug. It's kind of rxjs to include a workaround so the community can be shielded until a fix for Babel can land.

Issued filed by @Blesh: https://phabricator.babeljs.io/T7479

kwonoj pushed a commit that referenced this issue Jul 5, 2016
…nc` (#1807)

This moves the `async` property to be the last one defined, because babel will then not choke on the `,` after the property.

fixes #1806
@lock
Copy link

lock bot commented Jun 7, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants