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

Attempt to fix webpack module resolution by renaming graphql.ts module #8862

Merged
merged 2 commits into from
Sep 29, 2021

Conversation

benjamn
Copy link
Member

@benjamn benjamn commented Sep 28, 2021

May fix #8861, if my hunch is correct that webpack is resolving the 'graphql' in

import { isType } from 'graphql'

as importing from utilities/globals/graphql.ts module itself, rather than the graphql package, as suggested by the (possible exports: removeTemporaryGlobals) part of the error message:

WARNING in ./node_modules/@apollo/client/utilities/globals/graphql.js 4:4-10
export 'isType' (imported as 'isType') was not found in 'graphql' (possible exports: removeTemporaryGlobals)

The only relevant module that exports removeTemporaryGlobals is utilities/globals/graphql.ts, so renaming that module to something that cannot be confused with the graphql package should either fix the problem or at least shed more light on what's going on.

May fix #8861, if my hunch is correct that webpack is resolving the
```ts
import { isType } from 'graphql'
```
as importing from `utilities/globals/graphql.ts` module itself, rather
than the `graphql` package, as suggested by the "(possible exports:
removeTemporaryGlobals)" part of the error message:
```
WARNING in ./node_modules/@apollo/client/utilities/globals/graphql.js 4:4-10
export 'isType' (imported as 'isType') was not found in 'graphql' (possible exports: removeTemporaryGlobals)
```
The only relevant module that exports `removeTemporaryGlobals` is
`utilities/globals/graphql.ts`, so renaming that module to something
that cannot be confused with the `graphql` package should either fix the
problem or at least shed more light on what's going on.
@benjamn
Copy link
Member Author

benjamn commented Sep 28, 2021

Incredibly, this renaming fixes the reproduction provided in #8861. A pretty good guess, if I may say so myself!

Copy link
Contributor

@brainkim brainkim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t mind this being merged but the module resolution is just wrong and wonder if there is a deeper root cause which can be dealt with here or opened upstream.

@benjamn
Copy link
Member Author

benjamn commented Sep 29, 2021

@brainkim Looks like this was a result of preferRelative: true in webpack.config.js: #8861 (comment)

From my perspective, the deeper root cause of this problem is that webpack's resolve.preferRelative setting should not apply to resolution of modules in node_modules. If there was a way to disable it (in, say, @apollo/client/package.json), that would be nice, but I haven't found a good way (for us) to do that yet.

@benjamn benjamn merged commit becea12 into main Sep 29, 2021
@benjamn benjamn deleted the issue-8861-rename-utilities/globals/graphql-module branch September 29, 2021 15:29
@brainkim
Copy link
Contributor

IMHO no one should ever be using that option and I am shocked that it exists.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wont compile after upgrading webpack 5
2 participants