3

I know that this issue has been discussed a billion times, but it seems that none of the solutions I can find here are helping in my case.

This is what my polyfills.browser.ts looks like right now:

import 'ie-shim';
import 'core-js/es7/reflect';

import 'reflect-metadata';
import 'zone.js/dist/zone';

As stated before, I tried different approaches for solving this.

I tried adding all imports that are uncommented by default:

import 'core-js/es6/symbol';
import 'core-js/es6/object';
import 'core-js/es6/function';
import 'core-js/es6/parse-int';
import 'core-js/es6/parse-float';
import 'core-js/es6/number';
import 'core-js/es6/math';
import 'core-js/es6/string';
import 'core-js/es6/date';
import 'core-js/es6/array';
import 'core-js/es6/regexp';
import 'core-js/es6/map';
import 'core-js/es6/set';

I tried using

import "core-js/client/shim";

and also

import 'mdn-polyfills/Object.assign';

and

import 'core-js';

All of these were added to the top of polyfills.browser.ts

None seems to help and I keep getting Object doesn't support property or method 'assign' in IE11.

2
  • Can you give this a try npmjs.com/package/object-assign? Commented Oct 26, 2017 at 10:37
  • I had a look at it before, but as I understood, I would need to actually use it whenever assign is needed, right? The call in question, however, is somewhere in one of the node modules used. Commented Oct 26, 2017 at 10:40

2 Answers 2

3

Object.assign is ES2015 and is covered by a polyfill:

import 'core-js/es6/object';

Or for a broader range of ES2015 polyfills:

import 'core-js/es6';

The reason why it is preferable to list ES2015 polyfills in Angular application instead of importing core-js/es6 is that core-js/es6/promise polyfill is already covered by Zone.js and may cause problems,.

If this doesn't work and

Object doesn't support property or method 'assign'

error occurs, this means that polyfills bundle wasn't loaded in browser, or a piece of code where Object.assign occurs was evaluated before polyfills bundle was loaded.

Sign up to request clarification or add additional context in comments.

3 Comments

I just added a console.log() to the polyfills file, and I get an output in my app, which means that it is loaded. How can I find out if something is evaluated before the bundle is loaded?
Load it early in <head>. The way how the app is bundled depends on your setup. But of course, it's preferable for polyfills to be a separate bundle, because it should be loaded ASAP.
That was it, thanks! Had to make sure the order is correct in webpack :)
0

I had the same issue even using polyfill on IE11, but not every time. The problem was that sometimes main script was being loaded before polyfills, so I've made the following change in webpack config:

       new CommonsChunkPlugin({
-        name: 'polyfills',
-        chunks: ['polyfills']
+        name: ['polyfills', 'main'].reverse(),
       })

So now with just:

new CommonsChunkPlugin({
  name: ['polyfills', 'main'].reverse(),
})

it seems to work properly

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.