0

I am using AWS Chime SDK in a browser application. It is all working well but I'm concerned about the size of the JavaScript file being sent to the browser. I am using the singlejs option which is one of the demos in the amazon-chime-sdk-js project on GitHub. The size of amazon-chime-sdk.min.js is 865KB.

I looked at the code for the build, which uses rollup. rollup.config.js has:

input: 'src/index.js'

and index.js has:

export * from 'amazon-chime-sdk-js';

Logically I thought if I could limit what is exported that would reduce the size of the output but it is not clear to me how to do this. Even better would a way of inspecting what is actually called by my client and eliminate unnecessary code. I'd value guidance on what is the best way of achieving this.

timanderson
  • 843
  • 1
  • 10
  • 20
  • You can activate [tree shaking](https://rollupjs.org/guide/en/#tree-shaking) when bundling with rollup or webpack to reduce the size of your application. If you import only a sub module of the dependency in your application then the bundle will contain only the sub module required. – Troopers Oct 08 '20 at 12:45
  • Yes, the problem is I'm not running rollup on my own project. Singlejs is here: https://github.com/aws/amazon-chime-sdk-js/tree/master/demos/singlejs and what I'd like to do is to edit it to remove what I don't need and make the output smaller. – timanderson Oct 08 '20 at 18:48
  • Don't edit a dependency library, this will be a problem when upgrading the dependency. Instead import only what you want in your app or library and use a bundler like rollup and webpack which supports tree shacking : `import { ConsoleLogger, DefaultDeviceController, DefaultMeetingSession, LogLevel, MeetingSessionConfiguration } from 'amazon-chime-sdk-js';` – Troopers Oct 09 '20 at 09:23
  • The problem is that the Chime SDK for JavaScript doesn't support ES6 modules only Node modules https://github.com/aws/amazon-chime-sdk-js/issues/391 – timanderson Oct 10 '20 at 18:36

0 Answers0