1

After a fresh install of npm packages (deleted node_modules and package.lock.json) polyfills-es5 file started having additional code to define _toPrimitive function enter image description here

And when I load the app in IE I get @@toPrimitive must return a primitive value.

I debugged the IE and found that input = [Symbol [Object]] (typeof input === 'object) while in Chrome it is just a 'string'. debugging more I figured out the caller function enter image description here

So and as I checked in chrome it is just a string:

enter image description here

And in IE it is of type object:

enter image description here

I was able to find out that this function is added by babel. But I do not understand why it eventually started to be a case. Please, help me to understand what causes this code to be added like that. What dependency I need to rollback or maybe something change anywhere.

If I revert package.lock.json and reinstall node_modules this issue doesn't occur

4
  • 1
    Neither Angular 12 nor IE 11 are supported. Indeed, the release notes for Angular 12 indicate that they started to remove IE 11. I know some people may still be using these but your question is a couple of years too late.
    – stdunbar
    Commented Aug 9, 2023 at 21:50
  • Angular 12 does not support IE. And to be honest I wasn't even aware IE was still a thing Commented Aug 9, 2023 at 21:50
  • 1
    @ChristianVincenzoTraina IE support was dropped in v13. See here for the v12 support : v12.angular.io/guide/browser-support Commented Aug 9, 2023 at 22:40
  • Angular 12 does support IE 11, it is the last version where it is supported and during the building you get the message about that. There are still legacy systems that people need to maintain and sometimes such issues rise I appreciate your responses attention, but as I said, this is still relevant for some legacy systems and I expect other people to face this issue. Commented Aug 10, 2023 at 7:24

1 Answer 1

0

The "problem" is hiding in newer version of @babel/helpers. Since version 7.20.5 the defineProperties function started to call toPropertyKey. So this combination started to be included into the new output bundles code of this function.

The problem is solvable by adding @babel/helpers directly in package.json and specifying older version. I specified 7.14.0

"@babel/helpers": "~7.14.0"

So it should start working as it was before.

It doesn't mean that root problem is gone, the code still contains a Symbol which cannot be converted to string primitive. I put logging to this 'broken' code and logged each descriptor.key in IE:

enter image description here

There are 2 fields which are setup as keys for certain object. This object is from zoneJS infrastructure. I cannot tell right now if it may cause any problem. But this is how our code was working before. But I am still wondering why these 2 properties are like that...

Not the answer you're looking for? Browse other questions tagged or ask your own question.