aws-amplify / amplify-js

A declarative JavaScript library for application development using cloud services.
https://docs.amplify.aws/lib/q/platform/js
Apache License 2.0
9.42k stars 2.11k forks source link

@aws-amplify/core@4.3.1 brings in react-native #9119

Closed revmischa closed 10 months ago

revmischa commented 2 years ago

Before opening, please confirm:

JavaScript Framework

React

Amplify APIs

Not applicable

Amplify Categories

Not applicable

Environment information

``` # Put output below this line ❯ npx envinfo --system --binaries --browsers --npmPackages --duplicates --npmGlobalPackages System: OS: macOS 11.6 CPU: (8) x64 Intel(R) Core(TM) i7-6920HQ CPU @ 2.90GHz Memory: 1.75 GB / 16.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 14.15.4 - /usr/local/bin/node Yarn: 1.22.15 - /usr/local/bin/yarn npm: 8.0.0 - /usr/local/bin/npm Watchman: 2021.10.11.00 - /usr/local/bin/watchman Browsers: Brave Browser: 94.1.30.89 Chrome: 95.0.4638.54 Firefox: 82.0.3 Safari: 15.0 npmPackages: @ampproject/toolbox-optimizer: undefined () @aws-sdk/client-dynamodb: 3.34.0 => 3.34.0 @aws-sdk/client-lambda: 3.34.0 => 3.34.0 @aws-sdk/client-s3: 3.34.0 => 3.34.0 (3.6.1) @aws-sdk/types: 3.34.0 => 3.34.0 (3.6.1, 1.0.0-rc.10, 3.35.0, 3.22.0) @aws-sdk/util-credentials: 3.34.0 => 3.34.0 (3.22.0) @babel/core: undefined () @babel/preset-typescript: * => 7.15.0 @jdpnielsen/http-error: ^1.2.1 => 1.2.1 @jetkit/cdk-runtime: 2.0.15 => 2.0.15 @prisma/client: ^3.0.1 => 3.2.1 @selfage/lazy_instance: ^1.0.0 => 1.0.0 @shelf/jest-dynamodb: ^1.8.1 => 1.8.1 @testing-library/dom: ^8.1.0 => 8.7.2 @testing-library/jest-dom: ^5.14.1 => 5.14.1 @testing-library/react: ^12.0.0 => 12.1.2 @tsconfig/node14: ^1.0.0 => 1.0.1 @types/async-retry: ^1.4.3 => 1.4.3 @types/dotenv-flow: ^3.2.0 => 3.2.0 @types/faker: ^5.5.9 => 5.5.9 @types/lodash.clonedeep: ^4.5.6 => 4.5.6 @types/uuid: ^8.3.0 => 8.3.1 @typescript-eslint/eslint-plugin: ^4.33.0 => 4.33.0 @typescript-eslint/parser: ^4.33.0 => 4.33.0 @vercel/nft: undefined () amphtml-validator: undefined () arg: undefined () async-retry: undefined () async-sema: undefined () aws-sdk-client-mock: ^0.5.5 => 0.5.5 aws-xray-sdk: ^3.3.3 => 3.3.3 babel-jest: * => 27.2.4 bfj: undefined () cacache: undefined () ci-info: undefined () cli-select: undefined () commander: ^8.1.0 => 8.2.0 (2.20.3, 6.2.1, 3.0.2, 4.1.1, 2.13.0) comment-json: undefined () compression: undefined () concurrently: ^6.2.0 => 6.3.0 conf: undefined () constructs: 3.3.141 => 3.3.141 content-type: undefined () cookie: undefined () cross-spawn: undefined () css-loader: undefined () debug: undefined () devalue: undefined () dirname-filename-esm: ^1.1.1 => 1.1.1 dotenv-cli: ^4.0.0 => 4.0.0 dotenv-flow: ^3.2.0 => 3.2.0 esbuild-node-loader: ^0.4.3 => 0.4.3 escape-string-regexp: undefined () eslint: ^7.27.0 => 7.32.0 eslint-config-next: ^11.0.1 => 11.1.2 eslint-plugin-import: ^2.24.2 => 2.24.2 esmo: ^0.10.1 => 0.10.1 faker: ^5.5.3 => 5.5.3 file-loader: undefined () find-cache-dir: undefined () find-up: undefined () fresh: undefined () glob: undefined () graphql: ^15.5.2 => 15.6.1 (14.0.0) gzip-size: undefined () http-proxy: undefined () husky: ^4.3.0 => 4.3.8 ignore-loader: undefined () is-animated: undefined () is-docker: undefined () is-wsl: undefined () iso-url: ^1.1.5 => 1.1.5 jest: ^27.2.4 => 27.2.4 jest-config: ^27.2.4 => 27.2.4 jest-dynalite: ^3.4.4 => 3.4.4 jest-extended: ^1.0.0 => 1.0.0 jest-mock-extended: ^2.0.4 => 2.0.4 json-web-key: ^0.4.0 => 0.4.0 json5: undefined () jsonwebtoken: undefined () lint-staged: ^10.4.0 => 10.5.4 loader-utils: undefined () lodash.clonedeep: ^4.5.0 => 4.5.0 lodash.curry: undefined () lru-cache: undefined () mini-css-extract-plugin: undefined () nanoid: undefined () neo-async: undefined () next: ^11.0.1 => 11.1.2 ora: undefined () parse-url: ^5.0.7 => 5.0.7 postcss: ^8.3.5 => 8.3.9 (7.0.39, 8.2.15) postcss-flexbugs-fixes: undefined () postcss-loader: undefined () postcss-preset-env: undefined () postcss-scss: undefined () prettier: ^2.3.2 => 2.4.1 (2.2.1) prisma: ^3.2.1 => 3.2.1 prisma-appsync: ^1.0.0-beta.58.2 => 1.0.0-beta.58.2 prisma-appsync-cdk: 1.0.0 recast: undefined () resolve-url-loader: undefined () sass-loader: undefined () schema-utils: undefined () semver: undefined () send: undefined () slugify: ^1.5.3 => 1.6.1 source-map: undefined () string-hash: undefined () strip-ansi: undefined () terser: undefined () text-table: undefined () ts-jest: ^27.0.7 => 27.0.7 ts-node: ^10.4.0 => 10.4.0 typescript: 4.4 => 4.4.3 unistore: undefined () uuid: ^8.3.2 => 8.3.2 (3.4.0, 3.3.2) wait-for-expect: ^3.0.2 => 3.0.2 web-vitals: undefined () webpack: undefined () webpack-sources: undefined () zen-observable: undefined () npmGlobalPackages: @aws-cdk/cx-api: 1.88.0 @cloudflare/wrangler: 1.19.3 @jetkit/cdk-runtime: 2.0.13 @jetkit/cdk: 2.0.13 @nestjs/cli: 7.6.0 @remix-project/remixd: 0.3.5 @types/node: 15.6.1 aws-cdk: 1.124.0 cdk: 1.89.0 colors: 1.4.0 esbuild: 0.12.15 eslint: 7.32.0 esmo: 0.10.1 import-js: 4.0.2 js-beautify: 1.14.0 node-modules-cleaner: 1.0.4 npm: 8.0.0 prettier: 2.3.2 prisma: 3.0.2 rocketcdk: 0.2.1 serverless: 2.25.1 source-map-support: 0.5.19 ts-node: 10.4.0 tsc: 1.20150623.0+f2044a901165a2a97813772353b57dd9ed4796ca typescript: 4.4.3 vsce: 1.95.1 yalc: 1.0.0-pre.53 yargs: 16.2.0 ```

Describe the bug

❯ npm ls react-native
platform@1.0.0 ./platform
└─┬ frontend@0.5.0 -> ./packages/frontend
  └─┬ @aws-amplify/core@4.3.1
    └─┬ @aws-sdk/client-cloudwatch-logs@3.6.1
      └─┬ @aws-sdk/middleware-retry@3.6.1
        └─┬ react-native-get-random-values@1.7.0
          └─┬ react-native@0.66.0
            └─┬ @react-native-community/cli@6.1.0
              └── react-native@0.66.0 deduped

My project does not nee react-native but it's bring brought in via @aws-amplify/core

Expected behavior

Maybe declare it as a peer dependency?

Reproduction steps

Install @aws-amplify/core

Code Snippet

// Put your code below this line.

Log output

``` // Put your logs below this line ```

aws-exports.js

No response

Manual configuration

No response

Additional configuration

No response

Mobile Device

No response

Mobile Operating System

No response

Mobile Browser

No response

Mobile Browser Version

No response

Additional information and screenshots

No response

ericclemmons commented 2 years ago

Confirmed that this was a bug in https://unpkg.com/browse/@aws-sdk/middleware-retry@3.6.1/package.json but resolved in https://unpkg.com/browse/@aws-sdk/middleware-retry@3.40.0/package.json.

A PR @aws-amplify/core updated @aws-sdk/client-cloudwatch-logs to ^3.40.0 should resolve this.

/tmp on ☁️  us-east-1
❯ mkdir rn

/tmp on ☁️  us-east-1
❯ cd rn

/tmp/rn on ☁️  us-east-1
❯ git init

/tmp/rn on ☁️  us-east-1
❯ npm init -y
nWrote to /private/tmp/rn/package.json:

{
  "name": "rn",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}

   ╭───────────────────────────────────────────────────────────────╮
   │                                                               │
   │      New major version of npm available! 6.14.15 → 8.1.3      │
   │   Changelog: https://github.com/npm/cli/releases/tag/v8.1.3   │
   │               Run npm install -g npm to update!               │
   │                                                               │
   ╰───────────────────────────────────────────────────────────────╯

/tmp/rn is 📦 v1.0.0 via ⬢ v14.17.6 on ☁️  us-east-1
❯ npm

/tmp/rn is 📦 v1.0.0 via ⬢ v14.17.6 on ☁️  us-east-1
❯ npm install -g npm
/Users/ecclemm/.nvm/versions/node/v14.17.6/bin/npm -> /Users/ecclemm/.nvm/versions/node/v14.17.6/lib/node_modules/npm/bin/npm-cli.js
/Users/ecclemm/.nvm/versions/node/v14.17.6/bin/npx -> /Users/ecclemm/.nvm/versions/node/v14.17.6/lib/node_modules/npm/bin/npx-cli.js
+ npm@8.1.3
added 70 packages from 18 contributors, removed 289 packages and updated 148 packages in 7.163s

/tmp/rn is 📦 v1.0.0 via ⬢ v14.17.6 on ☁️  us-east-1 took 7s
❯ npm i @aws-amplify/core
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated sane@4.1.0: some dependency vulnerabilities fixed, support for node < 10 dropped, and newer ECMAScript syntax/features added
npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated uglify-es@3.3.9: support for ECMAScript is superseded by `uglify-js` as of v3.13.0

added 772 packages, and audited 773 packages in 26s

19 packages are looking for funding
  run `npm fund` for details

31 vulnerabilities (8 moderate, 23 high)

To address all issues, run:
  npm audit fix

Run `npm audit` for details.

/tmp/rn is 📦 v1.0.0 via ⬢ v14.17.6 on ☁️  us-east-1 took 26s
❯ npm ls react-native
rn@1.0.0 /private/tmp/rn
└─┬ @aws-amplify/core@4.3.4
  └─┬ @aws-sdk/client-cloudwatch-logs@3.6.1
    └─┬ @aws-sdk/middleware-retry@3.6.1
      └─┬ react-native-get-random-values@1.7.0
        └─┬ react-native@0.66.2
          └─┬ @react-native-community/cli@6.1.0
            └── react-native@0.66.2 deduped
evcodes commented 2 years ago

Issue is not resolved yet as upgrading the package leads to breaking changes

evcodes commented 2 years ago

Hello @revmischa, we are currently blocked on this issue because one of our dependencies brings in the polyfills so we need to wait for the sdk team to fix that. We are also going to postpone removing the react-native dependency in the core package because it would cause breaking changes to the rest of the library. We are working with the react-native team to get a better solution for this.

pelly-ryu commented 1 year ago

any updates?

stephenh commented 1 year ago

AFAICT this means no users of @aws-amplify/core can use React 18:

npm ERR! Could not resolve dependency:
npm ERR! peer react@"17.0.2" from react-native@0.66.0
npm ERR! node_modules/react-native
npm ERR!   peer react-native@"*" from @react-native-community/cli@6.1.0
npm ERR!   node_modules/@react-native-community/cli
npm ERR!     @react-native-community/cli@"^6.0.0" from react-native@0.66.0
npm ERR!   peer react-native@">=0.56" from react-native-get-random-values@1.7.0
npm ERR!   node_modules/react-native-get-random-values
npm ERR!     react-native-get-random-values@"^1.4.0" from @aws-sdk/middleware-retry@3.6.1
npm ERR!     node_modules/@aws-sdk/middleware-retry
npm ERR!       @aws-sdk/middleware-retry@"3.6.1" from @aws-sdk/client-cloudwatch-logs@3.6.1
npm ERR!       node_modules/@aws-sdk/client-cloudwatch-logs
npm ERR!       11 more (@aws-sdk/client-cognito-identity, ...)

It seems like this should be a big deal @evcodes ?

Honestly it would be great if @aws-amplify/core could just not depend on the aws-sdk at all. That is probably naive, but I don't think I've had an interaction with @aws-amplify that was not tripped up by aws-sdk dependency issues.

armenr commented 1 year ago

...Any movement on this? Folks, this is kinda absurd. What sort of Bias for Action or Customer Obsession is this? wtf...

abdallahshaban557 commented 1 year ago

Hello @armenr - as part of our next major version, we are going to be splitting up all dependencies that are react-native specific, to prevent this issue. Apologies this has taken us so long, we are on it. We will provide an update on this issue when our new version is out.

@stephenh - we are also writing our own clients for interacting with AWS services, so that we can produce the smallest bundle size possible, and also prevent some compatibility issues with some of the underlying dependencies.

armenr commented 1 year ago

Thanks for the update, and for all of the hard work @abdallahshaban557 & Amplify team! My complaint/surprise was more about the lack of update/communication than anything else.

I know how hard the Amplify team is constantly working to deliver fixes and new (and useful) things. :)

Looking forward to these updates, they all sound exciting. Thank you! 🥇

abdallahshaban557 commented 1 year ago

Hi @armenr - I understand. We are trying to be a lot better at keeping our community updated - and we will continue to work to improve in that area. Thank you for the kind words, and looking forward to hearing your feedback once we get our new version out!

cwomack commented 10 months ago

With the release of the latest major version of Amplify (aws-amplify@>6), this issue should now be resolved! Please refer to our release announcement, migration guide, and documentation for more information.