Use the new IE11 Polyfill package with PnPJS 1.2.4

Posted Thursday, November 8, 2018 3:17 PM by CoreyRoth

Recently, I posted about the error (TypeError: Object doesn't support property or method 'from') you received in Internet Explorer 11 (IE11) when you didn't include the necessary polyfills for PnP JS to work.  To resolve the error, previously you had to include the following Polyfills to provide support for things like proxy, fetch, and map.

import "core-js/modules/es6.promise"

import "core-js/modules/es6.array.iterator.js"

import "core-js/modules/es6.array.from.js"

import "whatwg-fetch"

import "es6-map/implement"

Now with PnPJS 1.2.4, this has been simplified a bit with a new single package.  First, install the package @pnp/polyfill-ie11.

npm install --save @pnp/polyfill-ie11

Now remove all of the previous imports from your web part class and replace it with the following single import.

import "@pnp/polyfill-ie11";

Now, give your code a try inside Internet Explorer.  All of your PnPJS calls should work normally.  What's nice about this version of the Polyfill si that we have support for SearchQueryBuilder which I believe wasn't there before.

You can read more about the new Polyfill package on the PnPJS site.

Comments

No Comments

Leave a Comment

(required) 
(required) 
(optional)
(required)