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

GraphQL "only one instance" error when using minified aws-amplify.min.js #820

Closed
jrasky opened this issue May 10, 2018 · 5 comments
Closed
Assignees

Comments

@jrasky
Copy link

jrasky commented May 10, 2018

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

Report a bug

What is the current behavior?

When including the minified build of aws-amplify from a CDN such as unpkg, graphql fails to load correctly.

index.html:

<script crossorigin src="https://unpkg.com/aws-amplify@0.3.3/dist/aws-amplify.min.js"></script>
instanceOf.js:15 Uncaught 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 t.default (instanceOf.js:15)
    at s (definition.js:98)
    at o (definition.js:84)
    at L (definition.js:253)
    at U (definition.js:257)
    at new i (wrappers.js:79)
    at i (wrappers.js:81)
    at Object.<anonymous> (introspection.js:427)
    at t (bootstrap 92871efc72a617fdd30f:19)
    at Object.<anonymous> (validate.js:13)

In particular, this is because graphql requires process.env.NODE_ENV="production" for minified builds. See graphql/graphql-js#1182, graphql/graphql-js#1174. In particular, aws-amplify does not take the recommended step in https://webpack.js.org/guides/production/#specify-the-environment:

https://github.com/aws/aws-amplify/blob/2bee05e427bea0b166a7bc787b50a2b4da54f79d/packages/aws-amplify/webpack.config.js#L22-L31

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than AWS Amplify.

What is the expected behavior?

aws-amplify loads correctly, as it does when using the non-minified version.

Which versions of Amplify, and which browser / OS are affected by this issue? Did this work in previous versions?

Chrome and Windows 10, although presumably this affects all browsers/OSs

You can turn on the debug mode to provide more info for us by setting window.LOG_LEVEL = 'DEBUG'; in your app.

@UnleashedMind UnleashedMind added the investigating This issue is being investigated label May 10, 2018
@elorzafe
Copy link
Contributor

Hi @jrasky we will have a new release very soon. That fix that problem if you use the published version.

If you build this repo master branch you will have the fixed version. The steps after cloning the repo are this.

yarn config set workspaces-experimental true
yarn
yarn bootstrap
yarn build

You can check dist files for aws-amplify on packages/aws-amplify/dist

@jordanranz
Copy link
Contributor

Going to close this as this should be fixed with the latest release.

Please reopen if you are still experiencing this issue.

@jordanranz jordanranz removed the investigating This issue is being investigated label Oct 31, 2018
@sappleg
Copy link

sappleg commented Nov 9, 2018

@jordanranz this is still happening for me. I'm using 1.1.9

@youngchingjui
Copy link

Am also experiencing this issue.

No issues when running expo start --no-minify.
However, when I run expo start --minify, I get the same error message as original poster.
I have aws-amplify v1.2.4

From my package.json:

  "dependencies": {
    "@aws-amplify/api": "^1.2.2",
    "@aws-amplify/pubsub": "^1.2.2",
    "@aws-amplify/storage": "^1.2.2",
    "@react-native-community/async-storage": "^1.6.2",
    "aws-amplify": "^1.2.4",
    "aws-amplify-react-native": "^2.2.3",
    "aws-serverless-express": "^3.3.6",
    "axios": "^0.19.0",
    "expo": "^34.0.1",
    "expo-av": "^6.0.0",
    "expo-constants": "~6.0.0",
    "expo-file-system": "^6.0.2",
    "expo-mail-composer": "^6.0.0",
    "expo-permissions": "^6.0.0",
    "express": "^4.17.1",
    "react": "16.8.3",
    "react-devtools": "^3.6.3",
    "react-dom": "^16.8.6",
    "react-native": "https://github.com/expo/react-native/archive/sdk-34.0.0.tar.gz",
    "react-native-fs": "^2.16.1",
    "react-native-gesture-handler": "~1.3.0",
    "react-native-reanimated": "~1.1.0",
    "react-native-sound": "^0.11.0",
    "react-native-svg": "~9.5.1",
    "react-native-vector-icons": "^6.6.0",
    "react-native-voice": "^0.3.0",
    "react-native-web": "^0.11.4",
    "react-native-xml2js": "^1.0.3",
    "react-navigation": "^4.0.0",
    "react-navigation-stack": "^1.5.1",
    "react-navigation-tabs": "^2.3.0",
    "xmldom": "^0.1.27"
  }

@github-actions
Copy link

This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels or Discussions for those types of questions.

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

No branches or pull requests

7 participants