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

Using the npm module in the browser #789

Closed
nowakj opened this issue Nov 11, 2015 · 7 comments
Closed

Using the npm module in the browser #789

nowakj opened this issue Nov 11, 2015 · 7 comments
Labels
feature-request A feature should be added or improved.

Comments

@nowakj
Copy link

nowakj commented Nov 11, 2015

Hi,

I ma trying to use the aws-sdk module in the browser (with webpack) by doing:
var AWS = require('aws-sdk');

When I try to get Cognito credentials it fails with the following error:
TypeError: AWS.CognitoIdentity is not a function
at CognitoIdentityCredentials.AWS.CognitoIdentityCredentials.AWS.util.inherit.createClients
at CognitoIdentityCredentials.refresh
at CognitoIdentityCredentials.get

It seems that it is not initialising the CognitoIdentity service.
If I require the dist file it works fine:
require('../../node_modules/aws-sdk/dist/aws-sdk');
but I would like to require the module instead of the specific file.

Is there any way to make this work with the module require?

Thanks

@jeskew
Copy link
Contributor

jeskew commented Nov 11, 2015

Hi @nowakj,

Have you tried using our script package for the browser? You can find more on how to use it in our user guide.

@nowakj
Copy link
Author

nowakj commented Nov 11, 2015

Hi jeskew,

I am able to use the packaged files that come in the 'dist' directory just fine.
However the model we have for our product is to do the packaging with webpack and use npm modules directly with 'require' or 'import'. I was hoping we could do the same with the aws-sdk npm as this would be more consistent with our approach.

Thanks,
Jacek

@jeskew
Copy link
Contributor

jeskew commented Nov 11, 2015

There was some discussion on how to use the SDK with webpack in #603. A few solutions were proposed, but I'm not sure if they'd work for everyone. Webpack support seems pretty popular so I'm going to mark this ticket as a feature request and keep it open for now.

@jeskew jeskew added the feature-request A feature should be added or improved. label Nov 11, 2015
@nowakj
Copy link
Author

nowakj commented Nov 11, 2015

I was able to solve the problems described in #603, so the module loads fine. but than fails at runtime as the CognitoIdentity service is not loaded.
It would be great if you could add webpack support. thanks!

@hassankhan
Copy link

Indeed, it would be really beneficial if the SDK was updated rather than us having to work around specific issues by trial and error.

@jeskew
Copy link
Contributor

jeskew commented Mar 20, 2017

Support for webpack was added in version 2.6.0

@jeskew jeskew closed this as completed Mar 20, 2017
@lock
Copy link

lock bot commented Sep 29, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@lock lock bot locked as resolved and limited conversation to collaborators Sep 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request A feature should be added or improved.
Projects
None yet
Development

No branches or pull requests

3 participants