Skip to content
This repository was archived by the owner on Sep 27, 2023. It is now read-only.

Commit bfac7c3

Browse files
committed
Update to use aws/aws-sdk-js#1123 explicit webpack support.
- 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.
1 parent 42d0e1d commit bfac7c3

File tree

6 files changed

+43
-192
lines changed

6 files changed

+43
-192
lines changed

Gruntfile.js

Lines changed: 0 additions & 91 deletions
This file was deleted.

README.md

Lines changed: 24 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,12 @@ migration.
9393
}
9494
```
9595

96-
* Install the required tools and dependencies into your project with `npm` (Node Package Manager, which is installed
97-
with Node.js):
96+
* Install the Amazon Cognito Identity SDK for JavaScript and the Webpack tool into your project with `npm` (the Node
97+
Package Manager, which is installed with Node.js):
9898

9999
```
100-
> npm install --save-dev webpack exports-loader source-map-loader
101-
> npm install --save amazon-cognito-identity-js aws-sdk jsbn sjcl
100+
> npm install --save-dev webpack json-loader
101+
> npm install --save amazon-cognito-identity-js
102102
```
103103

104104
These will add a `node_modules` directory containing these tools and dependencies into your
@@ -108,79 +108,27 @@ migration.
108108

109109
* Create the configuration file for `webpack`, named `webpack.config.js`:
110110

111-
* Using the included Amazon Cognito AWS SDK for JavaScript:
112-
113-
```js
114-
// If you wish to use a custom build of the AWS SDK for JavaScript, put the relative path to it
115-
// here, starting with `./`, eg `./vendor/my-aws-sdk-build.js`.
116-
// This build must include the Cognito Identity Service Provider service.
117-
var AWS_SDK_BUNDLE = 'amazon-cognito-identity-js/dist/aws-cognito-sdk.min.js';
118-
119-
module.exports = {
120-
// Example setup for your project:
121-
// The entry module that requires or imports the rest of your project.
122-
// Must start with `./`!
123-
entry: './src/entry',
124-
// Place output files in `./dist/my-app.js`
125-
output: {
126-
path: 'dist',
127-
filename: 'my-app.js'
128-
},
129-
// ... other configuration
130-
131-
// The current version of the AWS SDK for JavaScript does not work without extra configuration
132-
// under webpack, see https://github.com/aws/aws-sdk-js/issues/603.
133-
// This configuration uses the packaged output file as it is simple, see the issue for other
134-
// options with different tradeoffs.
135-
resolve: {
136-
alias: {
137-
'aws-sdk$': AWS_SDK_BUNDLE
111+
```js
112+
module.exports = {
113+
// Example setup for your project:
114+
// The entry module that requires or imports the rest of your project.
115+
// Must start with `./`!
116+
entry: './src/entry',
117+
// Place output files in `./dist/my-app.js`
118+
output: {
119+
path: 'dist',
120+
filename: 'my-app.js'
121+
},
122+
module: {
123+
loaders: [
124+
{
125+
test: /\.json$/,
126+
loader: 'json'
138127
}
139-
},
140-
module: {
141-
noParse: /aws-cognito-sdk/,
142-
// Optional, but makes debugging library code much nicer:
143-
preLoaders: [
144-
{
145-
test: /\.min\.js$/,
146-
loader: 'source-map'
147-
}
148-
],
149-
loaders: [
150-
{
151-
test: require.resolve(AWS_SDK_BUNDLE),
152-
loader: 'exports?AWSCognito'
153-
}
154-
]
155-
}
156-
};
157-
```
158-
159-
* Or to use the full AWS SDK for JavaScript:
160-
161-
```js
162-
var AWS_SDK_BUNDLE = 'aws-sdk/dist/aws-sdk.min.js';
163-
164-
module.exports = {
165-
// ... as before.
166-
167-
resolve: {
168-
alias: {
169-
'aws-sdk$': AWS_SDK_BUNDLE
170-
}
171-
},
172-
module: {
173-
noParse: /aws-sdk/,
174-
// preLoaders: as before
175-
loaders: [
176-
{
177-
test: require.resolve(AWS_SDK_BUNDLE),
178-
loader: 'exports?AWS'
179-
}
180-
]
181-
}
182-
};
183-
```
128+
]
129+
}
130+
};
131+
```
184132

185133
* Add the following into your `package.json`
186134

enhance.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { CognitoIdentityServiceProvider } from 'aws-sdk';
1+
import CognitoIdentityServiceProvider from 'aws-sdk/clients/cognitoidentityserviceprovider';
22
import * as enhancements from './src';
33

44
export * from './src';

package.json

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,17 @@
2828
"cognito",
2929
"identity"
3030
],
31+
"scripts": {
32+
"build": "webpack -p",
33+
"doc": "jsdoc src -d docs",
34+
"lint": "eslint src"
35+
},
36+
"main": "dist/amazon-cognito-identity.min.js",
37+
"dependencies": {
38+
"aws-sdk": "^2.6.0",
39+
"jsbn": "^0.1.0",
40+
"sjcl": "^1.0.3"
41+
},
3142
"devDependencies": {
3243
"babel-core": "^6.13.2",
3344
"babel-loader": "^6.2.4",
@@ -36,24 +47,7 @@
3647
"eslint-config-airbnb-base": "^5.0.2",
3748
"eslint-import-resolver-webpack": "^0.5.1",
3849
"eslint-plugin-import": "^1.13.0",
39-
"grunt": "^0.4.5",
40-
"grunt-contrib-jshint": "^0.10.0",
41-
"grunt-contrib-qunit": "^0.5.2",
42-
"grunt-contrib-uglify": "^0.6.0",
43-
"grunt-contrib-watch": "^0.6.1",
44-
"grunt-jsdoc": "^0.5.7",
4550
"jsdoc": "^3.4.0",
46-
"qunitjs": "^1.15.0",
4751
"webpack": "^1.13.1"
48-
},
49-
"scripts": {
50-
"build": "webpack -p",
51-
"doc": "jsdoc src -d docs",
52-
"lint": "eslint src"
53-
},
54-
"main": "dist/amazon-cognito-identity.min.js",
55-
"peerDependencies": {
56-
"jsbn": "^0.1.0",
57-
"sjcl": "^1.0.3"
5852
}
5953
}

src/CognitoUserPool.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18-
import { CognitoIdentityServiceProvider } from 'aws-sdk';
18+
import CognitoIdentityServiceProvider from 'aws-sdk/clients/cognitoidentityserviceprovider';
1919

2020
import CognitoUser from './CognitoUser';
2121

webpack.config.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,16 @@ module.exports = {
3030
externals: {
3131
// This umd context config isn't in configuration documentation, but see example:
3232
// https://github.com/webpack/webpack/tree/master/examples/externals
33-
'aws-sdk': {
34-
root: 'AWSCognito',
35-
commonjs2: 'aws-sdk',
36-
commonjs: 'aws-sdk',
37-
amd: 'aws-sdk'
33+
'aws-sdk/clients/cognitoidentityserviceprovider': {
34+
root: ['AWSCognito', 'CognitoIdentityServiceProvider'],
35+
commonjs2: 'aws-sdk/clients/cognitoidentityserviceprovider',
36+
commonjs: 'aws-sdk/clients/cognitoidentityserviceprovider',
37+
amd: 'aws-sdk/clients/cognitoidentityserviceprovider'
3838
},
3939
// Exclude 3rd-party code from the bundle.
4040
sjcl: true,
4141
jsbn: {
42-
root: 'window', // non-npm jsbn exports to global
42+
root: [], // non-npm jsbn exports to global
4343
commonjs2: 'jsbn',
4444
commonjs: 'jsbn',
4545
amd: 'jsbn'

0 commit comments

Comments
 (0)