Next.js: async generator vs syntax transform

Created on 21 Jan 2017  路  8Comments  路  Source: vercel/next.js

I don't know much about these things, but was wondering if there's a reason to prefer async generator/regenerator vs. something like fast-async which _claims_ to be 3-4 times faster?

Most helpful comment

So if you, for example make a component which has a static getInitialProps instead of static async getInitialProps it will fail.

To implement this properly we just need to wrap the getInitialProps return value with Promise.resolve(). (something like await Promise.resolve(this.getInitialProps())). It seems weird to me to rely on the parser for that behavior.

All 8 comments

Interesting. I'll benchmark changing this.

Apparently fast-async doesn't support calling await on normal functions that don't return a Promise. So if you, for example make a component which has a static getInitialProps instead of static async getInitialProps it will fail. Also, we have to drop the es2015 preset to implement fast-async, since it conflicts with babel-plugin-transform-runtime 馃槩 Also looked into kneden but that one is unmaintained from the looks of it.

If there is something else we can look into please let me know 馃憤 馃槃

Thanks for looking that up. Would be good to give the feedback over there

@timneutkens I opened an issue over there and there are suggestions on how to fix your concerns: https://github.com/MatAtBread/fast-async/issues/32#issuecomment-276014312

So if you, for example make a component which has a static getInitialProps instead of static async getInitialProps it will fail.

To implement this properly we just need to wrap the getInitialProps return value with Promise.resolve(). (something like await Promise.resolve(this.getInitialProps())). It seems weird to me to rely on the parser for that behavior.

@TooTallNate Fair point. Will have a look into that 馃憤

Going to close this as the fast-async functionality seems to be going to go into babel 7, which we use now for Next.js.

Was this page helpful?
0 / 5 - 0 ratings