-
-
Notifications
You must be signed in to change notification settings - Fork 110
Open
Description
As of #296, vue-cli-plugin-apollo is broken when using it in environments which don't include regenerator-runtime. The reason that this has gone mostly unnoticed (except for #386) seems to be that nearly everyone transpiles their bundles in ways which conceal the fact.
What causes the issue?
The usage of async/await in graphql-client/src/index.js.
The file is transpiled with build:graphql-client, which basically just uses @babel/preset-env. This preset includes IE11 and adds calls to regenerator-runtime, presuming that it's globally available.
Showcase:
- REPL of async function with default env preset: includes calls to the non-defined
regeneratorRuntime. - REPL of async function with default env preset minus IE11: does not include calls to
regeneratorRuntime.
How to resolve the issue?
I am no expert on distributing packages nowadays. I see two simple possible ways to remove the issue:
- Install regeneratorRuntime and import it in
graphql-client/src/index.js. Thedistoutput is then able to run as distributed, even in IE11 (but probably bloated in size). Edit: it seems that another / the recommended option for a library would be to add@babel/plugin-transform-runtimeto.babelrc. That would result in such output. - Change the babel config to exclude IE11 as transpile target. The
distoutput would be able to run on its own, except for browsers not supporting async/await.
One could also consider building / shipping two versions, one modern bundle output, and one maximum compatible commonjs output.
I am happy to open PRs in any of the directions described above.
vernandoRGN, batmanhit, dhritzkiv, petomi, Migushthe2nd and 2 more
Metadata
Metadata
Assignees
Labels
No labels