Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IE 11 + [email protected]: String.prototype.split doesn't work correctly #741

Closed
bloody-ux opened this issue Jan 2, 2020 · 14 comments
Closed

Comments

@bloody-ux
Copy link

With core-js 3.6.1: '/home/sessionCheck.json'.split(//+/) will get:

image

The correct result should be:
image

@zloirock
Copy link
Owner

zloirock commented Jan 2, 2020

How do you import core-js?

image

@randym
Copy link

randym commented Jan 2, 2020

@zloirock @bloody-ux

I was able to reproduce this in a browserify/babelify build when @babel/preset-env useBuiltIns is configured to 'usage' which adds the following core-js polyfills to the module doing a split with a regular expression.

  es.regexp.exec { "ie":"11" }
  es.string.split { "edge":"18", "ie":"11" }

In the short term, there where two ways I was able to work around this.

  1. Downgrade core-js to 3.5.0

  2. set useBuiltIns to 'entry' (assuming you are not importing core-js manually)

@zloirock
Copy link
Owner

zloirock commented Jan 2, 2020

@randym I tested this case too. Could you add a reproducible example?

@randym
Copy link

randym commented Jan 2, 2020

@zloirock I've setup a repo to start pulling in the polyfills that my client's app used and see if I can reproduce it in a 'bare-ish' bones example.

Just pulling in

es.regexp.exec { "ie":"11" }
es.string.split { "edge":"18", "ie":"11" }

In isolation was not enough to reproduce the problem.

I've sent both of you collaborator invites with the understanding that @bloody-ux and I bear the burden of reproduction.

@zloirock
Copy link
Owner

zloirock commented Jan 2, 2020

Still the same with the example from your repo:
image

I have no ideas about the order which could cause the problem, so waiting for that.

Seems it's caused by #732, I thought about possible problems like this, but I didn't find them.

@asapach
Copy link

asapach commented Jan 3, 2020

I was able to reduce the problem to:

import 'core-js/stable/string/split';

Once the regexp polyfills are included the problem goes away:

import 'core-js/stable/regexp';

@zloirock
Copy link
Owner

zloirock commented Jan 3, 2020

@asapach I can't find the problem in the code, however, that makes sense, I'll check it in IE11 little later. But in the @randym issue es.string.split injected only with es.regexp.exec.

@zloirock
Copy link
Owner

zloirock commented Jan 3, 2020

Could you check it with this patch?

@asapach
Copy link

asapach commented Jan 3, 2020

I've checked the fix and it does seem to address the problem in my use case.

@randym
Copy link

randym commented Jan 6, 2020

confirmed fix @zloirock / @asapach - thanks

nutgaard added a commit to navikt/modiapersonoversikt that referenced this issue Jun 9, 2020
Gjøres pga følgende issues;
JakeChampion/fetch#750
JakeChampion/fetch#748
zloirock/core-js#751
zloirock/core-js#741

I bunn og grunn, core-js@^3.6.0 introduserte støtte for
String.prototype.split med regex som har sticky-flag. Pga bug her så
fungerer ikke funksjonen som forventet noe mer i eldre IE11 versjoner.

E.g `"test".split(/e/) === ['t', 'e', 's', 't']`, denne burde gitt
`['t', 'st']`
@albert-asin
Copy link

I have the same problem with IE11 + core-js 3.6.5 + D3 + angular 9
I cannot downgrade to core-js 3.5.0
so, I found a workaround

I replaced the following line in my polyfills.ts
import 'core-js';

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

Note that the imports regexp and string are commented.

So when your application needs to do a split it's using the native function of the browser instead of the split function in core-js

I hope this can help someone

@artem1
Copy link

artem1 commented Dec 16, 2020

Same problem on core-js 3.8.1
@babel/preset-env with ie11 and useBuiltin: usage

image

image

And also can't repro without all code...

This regexp in superagent lib (parse http request headers), can't patch in lib ((

@artem1
Copy link

artem1 commented Dec 16, 2020

downgrade to core-js 3.5.0 helps (no es.string.split module in bundle now)

@Jokero
Copy link

Jokero commented Mar 9, 2021

With downgraded version I get an error related to promise: "Object doesn't support property or method 'allSettled'"

nutgaard added a commit to navikt/modiapersonoversikt that referenced this issue Apr 8, 2021
Var tidligere nødvendig for å låse core-js til 3.5.0 versjonen, siden alle nyere versjoner hadde en regex-bug.
Dette skal nå være fikset i siste versjon, og dette var kun ett problem i eldre versjoner av IE11 som ikke er mye brukt noe mer.
Tenker det derfor er innafor å teste ut om vi kan rydde opp litt i avhengighetene våre.

For bedre dokumentasjon om vi skal reverte denne, så inkluderer jeg den originale commit-meldingen som introduserte overskrivingen;

```
Gjøres pga følgende issues;
JakeChampion/fetch#750
JakeChampion/fetch#748
zloirock/core-js#751
zloirock/core-js#741

I bunn og grunn, core-js@^3.6.0 introduserte støtte for
String.prototype.split med regex som har sticky-flag. Pga bug her så
fungerer ikke funksjonen som forventet noe mer i eldre IE11 versjoner.

E.g `"test".split(/e/) === ['t', 'e', 's', 't']`, denne burde gitt
`['t', 'st']`
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants