javascriptamazon-web-servicesaws-chime-sdkamazon-chime

AWS Chime SDK - Javascript - ChimeSDK is not defined


I am trying to find (download/create) Chime SDK javascript file to include in my html page for creating meetings.

However, i cannot find a direct download anywhere. So, by following instruction on this page
(Bundling Chime SDK into a single .js file):
https://github.com/aws-samples/amazon-chime-sdk/tree/main/utils/singlejs

as follows:

git clone https://github.com/aws-samples/amazon-chime-sdk.git
cd amazon-chime-sdk/utils/singlejs
npm install
npm run bundle

I generated the javascript file (amazon-chime-sdk.min.js), and included it in my HTML page as follows:

<html>
<head>
    <script src="assets/js/amazon-chime-sdk.min.js"></script>
</head>
<body>
    Welcome!
    <script>
        //Error on next line: ChimeSDK is not defined!
        const logger = new ChimeSDK.ConsoleLogger(
            "ChimeMeetingLogs",
            ChimeSDK.LogLevel.INFO
        );
        const deviceController = new ChimeSDK.DefaultDeviceController(logger);
    </script>
</body>
</html>

However, i get this error:

Uncaught ReferenceError: ChimeSDK is not defined

What am I doing wrong here, is the javascript file not generated correctly?
Alternatively, where can I find Chime sdk client javascript to include in my html page?


Solution

  • The output bundled code was not having ChimeSDK global variable. Update the src/index.js file with the following code and then rebuild the code with npm run bundle.

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