Amplify-js: Does Amplify require zen-observable?

Created on 4 Dec 2019  ·  13Comments  ·  Source: aws-amplify/amplify-js

* 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?

bug

Most helpful comment

Alright, this should address it! https://github.com/aws-amplify/amplify-js/pull/4511

Finding out a way to validate this...

All 13 comments

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 [email protected]: No license field
[3/4] Finding dependency...
[4/4] Calculating file sizes...
=> Found "[email protected]"
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 :sweat_smile:

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

> [email protected] 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! https://github.com/aws-amplify/amplify-js/pull/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!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

leantide picture leantide  ·  3Comments

rygo6 picture rygo6  ·  3Comments

guanzo picture guanzo  ·  3Comments

lucasmike picture lucasmike  ·  3Comments

callmekatootie picture callmekatootie  ·  3Comments