Originally posted on 2020-10-20
Regenerating the AWS IoT Device SDK for JavaScript for a browser can be done with a quick script. First clone the Github repo:
git clone git@github.com:aws/aws-iot-device-sdk-js.git
Then go into the aws-iot-device-sdk-js directory:
cd aws-iot-device-sdk-js
You may need to install UglifyJS3 if you don't have it installed already. This will reduce the size of the generated JavaScript significantly.
sudo npm install uglify-js -g
And finally add this script, make it executable, and run it:
#!/usr/bin/env bash
export AWS_SERVICES=cognitoidentity
rm browser/aws-iot-sdk-browser-bundle*.js
npm run-script browserize
uglifyjs browser/aws-iot-sdk-browser-bundle.js -c -m -o browser/aws-iot-sdk-browser-bundle-min-uglifyjs.js
du -sh browser/*.js
NOTE: You must have some services listed in the AWS_SERVICES
variable. If you leave that variable empty it will include the entire AWS SDK.
The "uglified" output will be in the browser
directory and is called aws-iot-sdk-browser-bundle-min-uglifyjs.js
.