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

Module parse failed: Export 'gql' is not defined #50

Open
unzico opened this issue Nov 3, 2020 · 0 comments
Open

Module parse failed: Export 'gql' is not defined #50

unzico opened this issue Nov 3, 2020 · 0 comments

Comments

@unzico
Copy link

unzico commented Nov 3, 2020

Hi there,

thanks for this very useful plugin!
I've recently migrated a project to @apollo/client v3 and encountered an error with the way this plugin seems to remove the import statements.

Console error:

path/to/app/node_modules/@apollo/client/core/index.js 16:9
Module parse failed: Export 'gql' is not defined (16:9)
File was processed with these loaders:
 * ../../node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
|     enableExperimentalFragmentVariables = gql.enableExperimentalFragmentVariables,
|     disableExperimentalFragmentVariables = gql.disableExperimentalFragmentVariables;
> export { gql };

File related to the above error: (node_modules/@apollo/client/core/index.js)

[...]
import gql from 'graphql-tag';
export var resetCaches = gql.resetCaches, disableFragmentWarnings = gql.disableFragmentWarnings, enableExperimentalFragmentVariables = gql.enableExperimentalFragmentVariables, disableExperimentalFragmentVariables = gql.disableExperimentalFragmentVariables;
export { gql };

As you can see, @apollo/client is importing gql from graphql-tag and assigning a few vars before exporting it. This plugin seems to remove the import statement, which leads to the above error.

I was able to resolve this by setting importSources: ["@apollo/client"] via the configuration. However, this is a bad user experience for migrating projects because they would have to change all imports at once and I think, this plugin shouldn't touch any files located in node_modules. I propose, we exclude the node_modules directory.

What do you think? Do you have a better fix in mind?

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

1 participant