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

"Unexpected token" build error with legacy / stage 1 decorators (no @e-d/babel-transforms) #48

Closed
niranjan94 opened this issue Apr 30, 2019 · 5 comments · Fixed by #54
Closed
Labels
bug-upstream A bug that is not caused by ember-concurrency-decorators itself, but an upstream dependency

Comments

@niranjan94
Copy link

niranjan94 commented Apr 30, 2019

Code snippet in question:

export default class AppSearchComponent extends Component {

  @restartableTask
  *searchContent(keyword) {
    if (isEmpty(keyword)) {
      return [];
    }
    yield timeout(250);
    return yield this.store.query('content', { keyword });
  }

}

Error on build:

Build Error (broccoli-persistent-filter:Babel > [Babel: sandbox]) in sandbox/components/navigation/app-search.js

/Users/xyz/sandbox/app/components/navigation/app-search.js: Unexpected token (17:26)

  15 | 
  16 |   @restartableTask
> 17 |   *searchContent(keyword) {
     |                           ^
  18 |     if (isEmpty(keyword)) {
  19 |       return [];
  20 |     }

Dependencies include:

{
    "ember-concurrency": "^0.10.0",
    "ember-concurrency-decorators": "^1.0.0-beta.2",

    "ember-decorators": "^6.0.0",
    "ember-decorators-polyfill": "^1.0.4",

    "ember-cli-babel": "^7.7.3",
    "ember-cli": "~3.9.0",
    "ember-source": "~3.9.0"
}

And not using @ember-decorators/babel-transforms

@buschtoens
Copy link
Collaborator

This is caused by babel/babel#9852.

You can either:

@buschtoens buschtoens added the bug-upstream A bug that is not caused by ember-concurrency-decorators itself, but an upstream dependency label Apr 30, 2019
@buschtoens buschtoens changed the title Ember 3.9 - Unexpected token error while using decorators with class generator method "Unexpected token" build error with legacy / stage 1 decorators (no @e-d/babel-transforms) Apr 30, 2019
@niranjan94
Copy link
Author

@buschtoens thanks for the update 😄 Will wait for babel/babel#9912 to be merged. Using the assignment syntax in the meantime.

@buschtoens
Copy link
Collaborator

I just merged #54 and released it as v1.0.0-beta.3. If you manually apply the patch to @babel/parser as described in What happened to the fancy generator method syntax? or wait for it to be released officially, you can use the generator method syntax again.

@gabrielgrant
Copy link

gabrielgrant commented Jul 24, 2019

@buschtoens looks like the latest Babel release (7 days ago) is v7.5.5, which presumably includes babel/babel#9912 (merged 24 days ago). Does that mean this patch work-around is no longer needed in order to use the "fancy generator method syntax" and the note can be removed/examples updated?

FWIW, looks like ember-cli v3.11 still only requires ^7.4.3, while current HEAD requires ^7.5.5, which I think means this can be relied on once 3.12(-beta?) ships?

@buschtoens
Copy link
Collaborator

@gabrielgrant Yes. The fix was already released in v7.5.0. So, if you're on at least that version, everything should be groovy.

Also, the version of @babel/core in ember-cli itself doesn't actually matter. It's the version in ember-cli-babel, which is a dependency in your project's package.json.

If you are using yarn, you can force an upgrade of this @babel/core dependency by setting a resolution. If you're using npm or don't want to use a resolution, a clean re-installation of the dependencies (delete node_modules and any package manager lock files) should also do the trick.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-upstream A bug that is not caused by ember-concurrency-decorators itself, but an upstream dependency
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants