Skip to content

graphql/jsutils/instanceOf fails in development builds that rename variables #1316

Closed
@thheller

Description

@thheller

graphql version used is: [email protected].

shadow-cljs is a build tool for ClojureScript + JS that among other things enables using npm packages directly (via ClojureScript). To achieve this it uses the Closure Compiler extensively instead of the usual babel or webpack.

Closure will rename pretty aggressively and this causes some of the graphql/types/definition classnames to end up having the same constructor.name. The instanceOf check then falsely reports this as a problem and a check that is supposed to fail and return false throws an error instead.


Previous Report (before I figured out the problem)

A user reported a build issue when trying to use the the graphql package where I cannot figure out the cause. No compiler error or so occurs, only a runtime issue.

 Cannot use a "__Schema" from another module or realm.

Ensure that there is only one instance of "graphql" in the node_modules
directory. If different versions of "graphql" are the dependencies of other
relied on modules, use "resolutions" to ensure only one version is installed.

https://yarnpkg.com/en/docs/selective-version-resolutions

Duplicate "graphql" modules cannot be used at the same time since different
versions may have different capabilities and behavior. The data from one
version used in the function from another could produce confusing and
spurious results.

There is definitely only one graphql instance in the code and it isn't even used so it happens during initialization.

I sort of tracked this down to be a Closure Compiler issue which I reported here: google/closure-compiler#2898

I thought I'd raise this here as well. Maybe someone has a clue what might be happening. I have not used the graphql package myself but I'd like to resolve this problem.

All code is available here: https://github.com/thheller/issue-248

The two failing builds are

simple is using source maps. pseudo is simple but without source maps, instead it is pretty printed and using pseudo names (easier to step through the actual code and not what it used to be).

And the working whitespace-only build
https://code.thheller.com/issue-248/whitespace/

Really just hoping someone more familiar with the code has a clue what might be happening. Closure seems to be the cause here not graphql.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions