ReactWebChat error in SPFx and IE11 with Polyfills
See original GitHub issueVersion
4.4.2 of botframework-webchat 1.10 (latest) of SPFx
Describe the bug
First off, thanks for a solution that is very easy to integrate with React and directline, component works great everywhere except IE11. I’ve reviewed the other posts in the issues list related to IE11 and SPFx, most notably #2030, where the list of polyfills is pointed out. I’ve installed core-js and imported the same polyfills listed here: packages/bundle/src/index-es5.ts into my component and it still does not function in IE11. Occasionally, I will get an “Out of stack space” exception, but mostly the chat window will load, but does not show any messages. The out of stack space exception has a lengthy discussion on the SP Dev Docs repo here and I’ve tinkered with commenting out certain polyfills, but have not been able to get this thing working. Below is my component that my web part is loading:
IE:
Chrome/edge:
In IE console:
Note: in screenshot, I have set commented out since that is one that causes the out of stack space exception. I’ve also tried including the polyfills in the webpart.ts file and even importing an external polyfills.ts file, but none will work properly. If I am not importing something correctly, missing something, or there is any other advice, i’d greatly appreciate it. I’m hoping someone who has successfully implemented the React component in SPFx and has it working in IE can provide some insight. If there are further details needed, please let me know.
Steps to reproduce
- yo ‘@microsoft/sharepoint’ to create new SPFx project
- Install botframework-webchat and directline.
- gulp serve and view in IE11.
Expected behavior
Working web part in IE11.
Additional context
[Bug]
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (3 by maintainers)
Top GitHub Comments
Hello, I’ve also struggled with making BotFramework-Webchat work with SPFX for IE11. After trying out a lot of configurations, I’ve finally found one that works for me.
I’ll start out with the versions I’m using. This is what my package.json file looks like (minus irrelevant packages and information):
Besides adopting these versions, I’d also add the target and browserlist fields if they are not yet present in your package.json.
The next step is to add the babel loader with the presets to your webpack config. This is done in gulpfile.js. The way the configuration is loaded is similar to a .babel.rc file. At the top of the file I added the following line:
The babel configuration looks as follows:
The “entry” flag tells babel you will partially supply your own polyfills in the entrypoint of the application, which for me are fairly similar to the ones you have. In my experience, the symbol and promise polyfill imports crashed the webpart for me. Here are the corejs imports in my WebPart entry point:
Now comes the tricky part, it took me quite a while to do find out about this. The framework allows you to load external libraries (eg. from CDN) in the config/config.json file. I did this to load the botframework library. This will replace the version from npm_modules at runtime, but keep its typings. The property to set is called externals. My config.json file looks like this:
That’s it, if there are no other libraries installed in your project that cause polyfill conflicts, this setup should work for you. Hope it helps!
Needs priority confirmation