Usage of shimport makes legacy support prohibitively challenging #657
Description
Shimport is a super neat project, but its critical integration in recent Sapper apps makes supporting IE11 very challenging. While shimport may work in legacy browsers when the APIs it uses are properly polyfilled, there's no convenient way currently to include such polyfills in Sapper apps, as Sapper uses shimport to load all of the user code.
The best method of working around this issue I've found is to include a polyfill.io script tag before %sapper.scripts%
, but even so I've failed in coming up with the correct set of polyfills to include to get Shimport to work correctly.
Currently, I'm using the following features:
- Blob
- fetch
- Promise
- URL
- Map
- String.prototype.startsWith
- Array.from
- Array.prototype.keys (may be unnecessary)
- classList (pretty sure unnecessary)
Resulting in the following script tag:
<script crossorigin="anonymous" src="https://polyfill.io/v3/polyfill.min.js?features=Blob%2Cfetch%2CPromise%2CURL%2CElement.prototype.classList%2CArray.prototype.keys%2CMap%2CArray.from%2CString.prototype.startsWith"></script>
Using these polyfills, I get an Unsupported BodyInit type
error in IE11 when Shimport tries to load my client code, which seems to be caused when the fetch polyfill tries to use a body of type Blob. Am I missing any polyfills that would allow Shimport to work? Are there any other escape hatches I may be missing?
Ideally I'd like to remove the reliance on polyfill.io, as I fear it may not be polyfilling correctly which is what's causing the error, but I can't think of a better way to integrate polyfills before shimport is loaded using the current configuration options supported by Sapper. I'm currently using the rollup template, though I'd be happy to switch to webpack instead if that makes a workaround any easier.
An automatic workaround when compiling with --legacy
would be amazing, but if we can come up with a manual one in the meantime that would be really great.
Thanks, as always!