Parcel: 馃悰 amazon-cognito-identity-js dependency unresolved

Created on 24 Mar 2018  路  2Comments  路  Source: parcel-bundler/parcel

馃悰 BUG
When using parcel in a react project that also uses aws-amplify, parcel fails to resolve the dependency for amazon-cognito-identity-js even though it is correctly placed in node_modules/ by yarn.

Here is a repository with a minimal setup to reproduce the problem: https://github.com/dfrkp/parcel-test

馃 Expected Behavior

A bundle is created even if aws-amplify is used.

馃槸 Current Behavior

$ yarn start                                                                                                                                                                                                                                                       [13:38:01]
  yarn run v1.5.1
  $ parcel index.html
  Server running at http://localhost:1234
馃毃  /Users/user/Development/parcel-test/node_modules/aws-amplify/lib/Common/Facet.js:20:22: Cannot resolve dependency 'amazon-cognito-identity-js'
  18 | var AWS = require("aws-sdk/global");
  19 | exports.AWS = AWS;
> 20 | var Cognito = require("amazon-cognito-identity-js");
     |                       ^
  21 | exports.Cognito = Cognito;
  22 | var Pinpoint = require("aws-sdk/clients/pinpoint");
  23 | exports.Pinpoint = Pinpoint;

馃實 Environment

| Software | Version(s) |
| ---------------- | ---------- |
| Parcel | 1.6.2 |
| Node | 9.9 |
| Yarn | 1.5.1
| Operating System | macOS |

Bug

Most helpful comment

This happens because parcel tries to load the module from es/index.js instead of lib/index.js, see https://github.com/parcel-bundler/parcel/blob/fc041d03c36bf41ea73c398e8d177de1a456e796/src/Resolver.js#L220-L224

However, the es folder doesn't exist.

IMO this is a bug from amazon-cognito-identity-js since that folder should be there. There is an issue reported there about this: https://github.com/aws/aws-amplify/issues/517

Parcel could try to see if the entry specified by "module" or "jsnext:main" exists or not first but I feel like that's not necessary.

All 2 comments

This happens because parcel tries to load the module from es/index.js instead of lib/index.js, see https://github.com/parcel-bundler/parcel/blob/fc041d03c36bf41ea73c398e8d177de1a456e796/src/Resolver.js#L220-L224

However, the es folder doesn't exist.

IMO this is a bug from amazon-cognito-identity-js since that folder should be there. There is an issue reported there about this: https://github.com/aws/aws-amplify/issues/517

Parcel could try to see if the entry specified by "module" or "jsnext:main" exists or not first but I feel like that's not necessary.

If you're going the extra mile, reporting the actual missing file (and why it was used) would be better than falling back to the first existing file, if that's what you meant.
A stronger motivation for fixing this would be monorepos - where it would make it clear you just haven't built yet, rather than that resolution is broken.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

oliger picture oliger  路  3Comments

mnn picture mnn  路  3Comments

jzimmek picture jzimmek  路  3Comments

davidnagli picture davidnagli  路  3Comments

algebraic-brain picture algebraic-brain  路  3Comments