-
-
Notifications
You must be signed in to change notification settings - Fork 375
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 operator «*», expected punc «(» #578
Comments
Async/await should be supported, but generators are not. Since the error message contain an asterisk (*) I'm assuming you are using the latter. They are not supported by default because the transpiled output for generators is quite heavy. You can enable transpilation for generators by adding the specific Babel plugin to your |
Try updating preact-cli to v2.2.1 and using https://github.com/pluscubed/preact-cli-plugin-fast-async Alternatively:
In your preact.config.js file:
|
@Carnewal where can we find |
Hi @hibangun, You'll need to create the |
@matthewlynch works perfect, thanks! |
I'm getting the same error and am only using async/await. Shouldn't they be supported out of the box, since feature #3 is "Transparently code-split any component with an async! prefix"? |
The |
uglify doesn't understand generators I think the or alternatively leave the async in place for dev because it probably works out of the box in your browser |
Note: #617 adds async/await support by default for |
@indatawetrust Can you elaborate on that? |
@hibangun How did you make it work? I am using preact-cli 2.2.1 and added the suggested code but I am still getting the error. Maybe you could please share your babelrc and preact.confikg.js settings? |
I just used preact-cli@next and for some reason I had this issue when building! I can provide more info if you guys need, adding the above fast async fix worked for me... |
More info is always good |
@Carnewal 's trick worked.
Now, in export default class Home extends Component {
componentDidMount() {
this.fetchSomething()
}
fetchSomething = async () => {
let r = await fetch('/api')
}
... That broke
This is how I fixed it:
Now, I'm not sure what that all means but it definitely means that the latest |
preact build can not use async/await , how to fix it ,thanks
The text was updated successfully, but these errors were encountered: