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

Webpack Support #1123

Merged
merged 15 commits into from
Sep 9, 2016
Merged

Webpack Support #1123

merged 15 commits into from
Sep 9, 2016

Conversation

chrisradek
Copy link
Contributor

This PR allows the SDK to be used with webpack.
It also allows webpack and browserify to generate node bundles that include the SDK.

Services can also now be required individually. For example, you can require the S3 service in your code by doing the following:

var S3 = require('aws-sdk/clients/s3');

To get access to the AWS namespace (useful when sharing config across multiple services), you can do the following:

var AWS = require('aws-sdk/global');

Of course, you can continue to use the SDK as usual:

var AWS = require('aws-sdk');
var S3 = AWS.S3;

Notes:
For webpack, you will still need to add a json loader to your configuration.

@chrisradek chrisradek mentioned this pull request Sep 8, 2016
@chrisradek chrisradek changed the title Full webpack Webpack Support Sep 8, 2016
@coveralls
Copy link

coveralls commented Sep 8, 2016

Coverage Status

Coverage increased (+1.6%) to 90.535% when pulling a7f7882 on chrisradek:full-webpack into 02c54e1 on aws:master.

1 similar comment
@coveralls
Copy link

coveralls commented Sep 8, 2016

Coverage Status

Coverage increased (+1.6%) to 90.535% when pulling a7f7882 on chrisradek:full-webpack into 02c54e1 on aws:master.

This was referenced Sep 8, 2016
@@ -0,0 +1,14 @@
require('../lib/node_loader');
var AWS = require('../lib/core');
var Service = require('../lib/service');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

core.js already requires service.js, and the Service constructor can already be accessed at AWS.Service. Why does it need to be required here? We also wouldn't need to export Service in service.js

@LiuJoyceC
Copy link
Contributor

:shipit: pending changes

@coveralls
Copy link

coveralls commented Sep 9, 2016

Coverage Status

Coverage increased (+1.9%) to 90.802% when pulling bc1d2fa on chrisradek:full-webpack into 02c54e1 on aws:master.

@chrisradek
Copy link
Contributor Author

Changes made, merging!

@chrisradek chrisradek merged commit c21b18a into aws:master Sep 9, 2016
chrisradek added a commit that referenced this pull request Sep 9, 2016
simonbuchan added a commit to skilitics/amazon-cognito-identity-js that referenced this pull request Sep 9, 2016
- Update README.md to use new aws-sdk webpack support.

- Simplify NPM install by making the dependencies direct.

  This is apparently OK for aws-sdk to do, so we may as well make it nicer
  for the end-user.

- Remove old grunt build and deps.
@simonbuchan
Copy link

Looks good! I hit an issue where using the non-client public APIs like default config or CognitoIdentityCredentials without pulling in all the default services has to import from aws-sdk/lib/core, so it may be a good idea to mention that somewhere:

import { config, CognitoIdentityCredentials } from 'aws-sdk/lib/core';

@simonbuchan
Copy link

Also the changes to dist-tools/service-collector broke my older hacky build that was munging and injecting the output of that into my entry, due to the missing .json, but probably not a big use case :)

@simonbuchan
Copy link

Damn, just noticed that if you load aws-sdk/lib/core before any clients, then you need to first import aws-sdk/lib/node_loader, which is ugly.

@chrisradek
Copy link
Contributor Author

@simonbuchan
You can get the global AWS object from aws-sdk/global. If you do that, you should be able to set config on the AWS object, and any services instantiated after that will use that configuration.

@simonbuchan
Copy link

That is much better, although it still also adds it to the global which is
a little bad mannered

On Sat, 10 Sep 2016, 02:30 Christopher Radek notifications@github.com
wrote:

@simonbuchan https://github.com/simonbuchan
You can get the global AWS object from aws-sdk/global. If you do that,
you should be able to set config on the AWS object, and any services
instantiated after that will use that configuration.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#1123 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/ABwVo5dr20Fmb9kJ3hKgtVqwAwOoJwAnks5qoW1qgaJpZM4J3qN6
.

@kellyjanderson
Copy link

@chrisradek As this change has been merged, can information about using with Webpack be added to the documentation?

https://github.com/aws/aws-sdk-js/blob/master/doc-src/guide/browser-intro.md

@chrisradek
Copy link
Contributor Author

@kellyjanderson
The guide in this repo is out of date. A new guide has been published, with information about using webpack here:
http://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/webpack.html

The updated link to the new guide is in our readme:
https://github.com/aws/aws-sdk-js#usage-and-getting-started

The new guide is maintained separately from this repo, but we can remove the old guide to avoid confusion.

@lock
Copy link

lock bot commented Sep 28, 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 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants