Issue in IE11 when importing plugins from @capacitor/core
See original GitHub issueThe following produces an error in IE11 about proxy not being defined:
import { Plugins } from '@capacitor/core'
const { Device } = Plugins
console.log(Device)
The error message in the console in my swedish IE11 says: “Proxy har inte definierats” (Proxy has not been defined).
Will this be fixed?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:5
- Comments:17 (10 by maintainers)
Top Results From Across the Web
How to fix import { Plugins } from '@capacitor/core'
I'm following a tutorial and I cant proceed until I fix it.. import { Plugins } from '@capacitor/core'; import { Storage} = Plugins;....
Read more >Updating to 3.0 | Capacitor Documentation
Capacitor plugins should be updated to use the new plugin registration APIs (see the Upgrade Guide for plugins), which will allow them to...
Read more >How to Use Capacitor Plugins: Core & Others
Learn how to use Capacitor Core Plugins as well as those made by the community. These allow portals to use native functionality with...
Read more >Resolving Internet Explorer 11 caching issues with Angular
import { Injectable } from '@angular/core'; import { HttpHandler, ... Ionic Storage & Awesome Cordova Plugins/Capacitor plugins across a ...
Read more >Ionic Capacitor
Ionic Capacitor is a cross-platform app runtime that makes it easy to build web apps that run natively on iOS ... import {...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I responded in another issue, but we’re strongly leaning towards not supporting IE 11. By supporting it, we’ll have to invest time on IE 11 instead of making Capacitor better for all the other platforms we support. Also, IE 11 does not support any PWA APIs.
Various stats show IE 11 usage at < 3% worldwide, and once we get into production ready status that number should drop even more.
It’s time to move on.
I think there’s a difference between not supporting IE11, and actively breaking it. Unfortunately
Proxy
is one of those rare JavaScript API that can’t be polyfilled on older engines. For instance, the only viable polyfill requires you to know the properties you want to proxy at creation time, which is effectively the same as defining lots of Object property getters, and can’t be used in Capacitor’s case.IMO PWAs are more than a set of APIs: the “Progressive” part means that the web apps get progressively better on newer engines, yet still work across all devices, as per the first sentence from Google’s PWA checklist:
The “Works in any browser” part is re-stated as item #2 in that same checklist.
As much as I’d love to agree with you, the sad reality is that those few percents often include the most valuable consumers for many businesses, as a large part of fortune 500s are still running IE11, often because they also have to support legacy IE11-only web apps in parallel.
Don’t get me wrong: we all hate IE11 here, but unfortunately most of us don’t have the luxury of just ignoring it.
The issue with using a conditional import is that it works until it doesn’t: I was doing the same trick, until Webpack code-splitting algorithm saw that that import are required from multiple places, and decided to optimize it by inlining the code into the
main
app bundle, effectively silently breaking IE11.In addition, while on the surface Capacitor looks like a modern ES module-based library, the simple fact of importing Capacitor (
import { Capacitor } from '@capacitor/core';
) creates a counter-intuitive side-effect (effectively breaking tree-shacking) by instantiatingCapacitorWeb
& exposing it on the global object, which I’d argue is another problem in itself.Anyway, since Capacitor’s use of
Proxy
is limited to throwing a Promise rejection when trying to access an unavailable plugin, I’d argue that said use should just be guarded: it means that trying to access an unavailable plugin will throw in IE11 (instead of returning a Promise rejection), but at least Capacitor won’t throw a global Syntax Error on import anymore (and not trying to use an unavailable plugin can be controlled on the caller side, i.e. by the user).