StackOverflow still delivers, fixes my Rollup.js problem

I hear plenty of complaints about StackOverflow, the developer Q&A site. Top of the list is unfriendliness and/or arguing about whether a question is well put rather than, well, answering the question.

For example, this Reddit post yesterday:

“It’s been three years since a question I posted to SO wasn’t closed within the first ten minutes of posting it and downvoted for good measure (that’ll teach me to use the site like it’s intended!).”

No doubt the complaints have some validity. StackOverflow is a kind of social media as well as a technology site and all social media sites have their problems.

Nevertheless, it remains a wonderful resource.

I am using the AWS Chime SDK for JavaScript in a project. I am using ASP.NET, it is not an SPA (Single Page Application), and it is not using React. The SDK though is primarily designed to be used with Node.js and a bundler like Webpack, fitting I guess with the majority of web applications being built today. The solution AWS provides for developers like myself is presented as a demo called singlejs.  This uses rollup.js to bundle the Chime SDK for JavaScript into a single file that can be used in any plain ordinary web page. A couple of weeks ago, someone got around to updating the demo to use version 3.x of the SDK.

I guess the committer checked that the demo worked and generated a JavaScript file, but did not actually check that it was usable. The way it is meant to work:

In a browser environment, window.ChimeSDK will be available. You can access Chime SDK components by component name. For example, you can create a meeting session and configure the meeting session using window.ChimeSDK.

Unfortunately the newly generated amazon-chime-sdk.min.js did not create this global variable, even though it is specified at the name property in rollup.config.js. I puzzled over this problem and tried to fix it in various ways, using different versions of rollup and the plugins it uses. I noted the problem in a GitHub issue on the relevant AWS repository but no response yet. Since it made it impossible for me to upgrade my project to the version 3.x of the SDK it was a significant problem.

I posted a question on StackOverflow. It did not attract many views, and at the time of writing it has only been viewed 31 times. I was not optimistic.

As so often with these kinds of problems, the fix is super simple. The source file in the singlejs demo, the one which Rollup bundles, has just one line of JavaScript:

export * from ‘amazon-chime-sdk-js’;

Someone popped up, 2 days after my post, and commented:

Update the src/index.js file with the following code and then rebuild the code with npm run bundle. Rollup recommends a default export if we have only single export.

export * as default from ‘amazon-chime-sdk-js’;

Indeed, that fixes it. So thank you to Vishnu S Krish, who for no reward has posted a solution that works, ahead of those busy AWS developers working on the project who have so far ignored it.

Thank you too to StackOverflow. It is imperfect; but it is not full of spam, it is a pleasant site to use and not afflicted by intrusive ads and popups, and it has a ton of good solutions.