JakeChampion/polyfill-library

[bug] Issue with the Reflect.construct polyfill ?

clempat opened this issue · 6 comments

What

I am getting exception when Reflect.construct polyfill is loaded on a bare next JS project.

Details

Steps

My issue is on a complex project, but I tried to reproduce it with the minimal setup:

  1. Create new next JS project using npx create-next-app nextjs-blog --use-npm --example "https://github.com/vercel/next-learn/tree/master/basics/learn-starter"
  2. Add <script src="https://polyfill.io/v3/polyfill.min.js?features=Reflect.construct" /> in Head in index.js
  3. Run yarn dev
  4. Open the browser, which will load this polyfill. For me, I am using Opera (Version:83.0.4254.62 (arm64))

What do I get

I get the following error:

TypeError: Cannot read properties of undefined (reading 'headManager')

What do I expect

No error

Comments

The fact I believe it comes from the polyfill is that this same project will work on other browsers which does not load this polyfill. Actually, it will work in opera without the polyfill.
On the production project, the link is created using polyfill-service-url-builder. The other looks working as expected.

Same here on opera too with the following version

Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.82 Safari/537.36 OPR/84.0.4316.14

It is not polyfiled in another chrome-like browser with chrome 98.0.4758.88

@jdeniau thanks for the issue, do you know if that version of opera supports Reflect.construct without the polyfill?

@JakeChampion Apparently it does work since Opera 36

Tested in this Opera version and it is working :
image

As a matter of fact, all Reflect functionnality is available in Opera 36 : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect#browser_compatibility

I will submit a PR

But will it still an issue for the browsers not having this functionality?

@clempat tested on Opera 34 Windows on browserstack and the issue I did have is not present