awslabs / aws-mobile-appsync-sdk-js

JavaScript library files for Offline, Sync, Sigv4. includes support for React Native
Apache License 2.0
917 stars 265 forks source link

minifying aws-appsync breaks graphql #715

Open jamesmillerburgess opened 2 years ago

jamesmillerburgess commented 2 years ago

Note: If your issue/feature-request/question is regarding the AWS AppSync service, please log it in the official AWS AppSync forum

Do you want to request a feature or report a bug?

Report a bug.

What is the current behavior?

Running any package that imports from aws-appsync through esbuild with the --minify flag puts it in an unrunnable state due to an error with the graphql package:

Error: Cannot use e "__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.
    at cbe (C:\Users\James\Documents\GitHub\aws-appsync-minify\build\index.js:55:23803)
    at Io (C:\Users\James\Documents\GitHub\aws-appsync-minify\build\index.js:66:3518)
    at pA (C:\Users\James\Documents\GitHub\aws-appsync-minify\build\index.js:66:3314)
    at lF (C:\Users\James\Documents\GitHub\aws-appsync-minify\build\index.js:66:6209)
    at dF (C:\Users\James\Documents\GitHub\aws-appsync-minify\build\index.js:66:6242)
    at new Ro (C:\Users\James\Documents\GitHub\aws-appsync-minify\build\index.js:66:5897)
    at Ro (C:\Users\James\Documents\GitHub\aws-appsync-minify\build\index.js:66:5915)
    at C:\Users\James\Documents\GitHub\aws-appsync-minify\build\index.js:68:8959
    at C:\Users\James\Documents\GitHub\aws-appsync-minify\build\index.js:1:741
    at C:\Users\James\Documents\GitHub\aws-appsync-minify\build\index.js:68:14268

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.

Simplest reproduction is here: https://github.com/jamesmillerburgess/aws-appsync-minify

What is the expected behavior?

Since other libraries, like graphql-tag can be minimized without breaking graphql, my expectation is that aws-appsync will also work with minification.

Which versions and which environment (browser, react-native, nodejs) / OS are affected by this issue? Did this work in previous versions?

NodeJs. I tried with much older versions of aws-appsync and they all had the same issue.