You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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. The dist output 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-runtime to .babelrc. That would result in such output.
Change the babel config to exclude IE11 as transpile target. The dist output 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.
The text was updated successfully, but these errors were encountered:
philipp-tailor
added a commit
to bird-labs/vue-cli-plugin-apollo
that referenced
this issue
Oct 22, 2020
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 toregenerator-runtime
, presuming that it's globally available.Showcase:
regeneratorRuntime
.regeneratorRuntime
.How to resolve the issue?
I am no expert on distributing packages nowadays. I see two simple possible ways to remove the issue:
graphql-client/src/index.js
. Thedist
output 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-runtime
to.babelrc
. That would result in such output.dist
output 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.
The text was updated successfully, but these errors were encountered: