aws-amplify / amplify-js

A declarative JavaScript library for application development using cloud services.

Home Page:https://docs.amplify.aws/lib/q/platform/js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Does Amplify require zen-observable?

TriangularCube opened this issue · comments

** Which Category is your question related to? **
Auth

** What AWS Services are you utilizing? **
Just Auth

After updating from 1.5 to 2.2 2.1.1, it seems Auth is now missing a dependency of zen-observable that must be manually installed. This doesn't seem to be documented anywhere. Is the documentation simply lagging behind or am I missing something?

Hi @TriangularCube,

Can you share your package.json and the exact error you're getting?

I was testing this out in a sandbox (https://codesandbox.io/s/httpsgithubcomaws-amplifyamplify-jsissues4506-sr9l1), and zen-observable appears to come in from a sub-dependency of aws-amplify:

yarn why zen-observable
yarn why v1.16.0
warning package.json: No license field
[1/4] Why do we have the module "zen-observable"...?
[2/4] Initialising dependency graph...
warning https-githubcom-aws-amplify-amplify-js-issues-4506@1.0.0: No license field
[3/4] Finding dependency...
[4/4] Calculating file sizes...
=> Found "zen-observable@0.8.15"
info Reasons this module exists
   - "aws-amplify#@aws-amplify#pubsub" depends on it
   - Hoisted from "aws-amplify#@aws-amplify#pubsub#zen-observable"
   - Hoisted from "aws-amplify#@aws-amplify#api#zen-observable"

It is a sub-dependency of aws-amplify, but this is not documented anywhere, and is not automatically installed when I use npm install. I can fix it by manually installing zen-observable.

I can't duplicate this in codesandbox, and I have no idea how it's installing dependencies, so here's a simple package.json I threw together.

{ "name": "amplify-test", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "start": "parcel index.js --open" }, "keywords": [], "author": "", "license": "ISC", "dependencies": { "@aws-amplify/auth": "^2.1.1" }, "devDependencies": { "parcel-bundler": "^1.12.4" } }

Simply run npm i, then add import Auth from "@aws-amplify/auth"; to the top of index.js, and parcel should fail to compile.

I notice you're using Yarn though, so maybe it's an NPM issue?

EDIT: here's the error I'm getting:

? /Users/tempest/Desktop/Projects/PS/amplify-test/node_modules/@aws-amplify/core/lib-esm/Util/Reachability.js:1:28: Cannot resolve dependency 'zen-observable'

1 | import * as Observable from 'zen-observable';
| ^
2 | var ReachabilityNavigator = /** @Class */ (function () {
3 | function ReachabilityNavigator() {
4 | }
`

Oh, I see: the original post mentioned 2.2, which only exists for aws-amplify. @aws-amplify/auth's latest is 2.1.1 as you mentioned.

I'll validate some more. Thanks!

Oh, I see: the original post mentioned 2.2, which only exists for aws-amplify. @aws-amplify/auth's latest is 2.1.1 as you mentioned.

You're right, my bad 😅

Hey no worries! Thanks for sharing your package.json and the clear steps for reproducing. I'll let you know what I find 🙏

I'm struggling to reproduce this. I'm going to spin up a local repo with npm like you mentioned & try that...

https://codesandbox.io/s/youthful-sky-h0pok
Screen Shot 2019-12-04 at 9 12 47 AM

@TriangularCube Reproduced!

https://github.com/ericclemmons/amplify-js-issues-4506

Screen Shot 2019-12-04 at 9 17 39 AM

npm run start

> amplify-test@1.0.0 start /private/tmp/4506
> parcel index.js --open

Server running at http://localhost:1234
🚨  /private/tmp/4506/node_modules/@aws-amplify/core/lib-esm/Util/Reachability.js:1:28: Cannot resolve dependency 'zen-observable'
> 1 | import * as Observable from 'zen-observable';
    |                            ^
  2 | var ReachabilityNavigator = /** @class */ (function () {
  3 |     function ReachabilityNavigator() {
  4 |     }

Thanks for your clear steps & the package.json. It's interesting that CodeSandbox using Parcel doesn't have the issue, while we do locally...

yarn vs. npm doesn't make a difference. I'm going to dig into it more. There have been releases recently, and it looks like @aws-amplify/core has a hard-dependency on zen-observable without it being explicitly included.

Alright, this should address it! #4511

Finding out a way to validate this...

Thanks so much!

Alright, this should address it! #4511

Finding out a way to validate this...

Awaiting for the next release as I step into this error too. Glad to know it got fixed on that PR.

@ericclemmons this seems to have been merged and released. Is this safe to close?

Safe to close! Thanks for everyone's help!

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.