-
-
Notifications
You must be signed in to change notification settings - Fork 27
Description
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?