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

could not run well with async/await(regeneratorRuntime actually) #5559

Closed
JounQin opened this issue Apr 29, 2017 · 8 comments
Closed

could not run well with async/await(regeneratorRuntime actually) #5559

JounQin opened this issue Apr 29, 2017 · 8 comments

Comments

@JounQin
Copy link
Contributor

JounQin commented Apr 29, 2017

Version

2.3.0

Reproduction link

https://github.com/JounQin/vue-hackernews-2.0/blob/async-await/src/store/actions.js

Steps to reproduce

remove L1 and L9

What is expected?

I've add 'regenerator-runtime/runtime' in client and server entry, which should register global.regeneratorRuntime already.

What is actually happening?

throw Error ReferenceError: regeneratorRuntime is not defined every time


It worked before vue-server-renderer 2.3.0

@LinusBorg
Copy link
Member

LinusBorg commented Apr 29, 2017

Can you explain what is happening, what the error is that you got?

@posva
Copy link
Member

posva commented Apr 29, 2017

Sorry, but this is related to babel config not to Vue
I know using the transform-runtime works (like in the webpack template)

@posva posva closed this as completed Apr 29, 2017
@JounQin
Copy link
Contributor Author

JounQin commented Apr 29, 2017

@posva Before migrating to new SSR solution, it worked just fine by using regenerator-runtime/runtime, so I think that it does be related to Vue.

What means the new SSR solution breaks global context of Node.js IMO.

@yyx990803
Copy link
Member

@JounQin this is a change caused by runInNewContext: false. I see that you've figured out you need to register it explicitly on the bundle's global context - this will be fixed in the next release.

@yyx990803
Copy link
Member

@JounQin after thinking about it, I think the 2.3.0 behavior should be preserved. The bundle should have a separate global context to prevent it from affecting the server process. For polyfills that modify global, the proper solution is either explicitly attach it to global inside bundle code (like you did), or whitelist it from server externals.

@JounQin
Copy link
Contributor Author

JounQin commented May 1, 2017

@yyx990803 Thanks for your explanation and whitelisting regenerator-runtime/runtime from server externals works fine for me.

@jonaskuiler
Copy link

@JounQin Do you have a code example? I don't really understand what I have to do to make this work correctly. Are you using webpack-node-externals?

@JounQin
Copy link
Contributor Author

JounQin commented May 4, 2017

@jonaskuiler After Vue 2.3.2, there is no need to do that if you are still using runInNewContext: false

Of course, if you running with Vue 2.3.0 or runInNewContext: 'once', you can do like this: https://github.com/JounQin/vue-ssr/blob/636bd0625bbe6a5efaa6f84409035eb86e97bfe4/build/webpack/server.babel.js#L58

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

5 participants