-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
polyfills-legacy.js throw error: Cannot assign to read only property 'prototype' of function #8287
Comments
Hello @daoerche. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with |
|
There's nothing I can do without a reproduction. |
Thank you very much if you would like to help me~ It requires you to try it out on a Windows computer, then follow these steps:
The QQ browser version 9.7 installation package has been out of print on the market, which is passed down from generation to generation within our company. |
I was able to reproduce it and found a interesting debug log.
It seems vite is injecting the same polyfill two times. |
It seems it is not affecting this. |
I don't get it! But it's okay so far, I haven't found any problems using the above fix method, thanks again~ |
It was reproducible without Vite. So it is a core-js's bug. |
ok~ |
core-js Added a workaround in 3.22.7. |
Describe the bug
When I use the @vitejs/plugin-legacy plugin to generate polyfills-legacy.js, it throws an error in QQ browser version 9.7:
And this error will cause the later injected Systemjs not to be initialized and executed, resulting in the System object not being found and the page js unable to load and run.
The reason for this is because polyfills-legacy.js tries to assign undefined to Array.prototype[Symbol.iterator].prototype, but in QQ browser version 9.7, this value is not writable, and the generation of polyfills-legacy chunk It is built by vite using es build, which makes the chunk enter strict mode by default, resulting in an error.
This issue should cause errors in all browsers with this feature. Although currently I only encountered it in the 9.7 version of the QQ browser.
At present, I solved it by adding a polyfillUseStrict parameter to the local plugin-legacy plugin through patch-package to control the polyfill chunk not to use strict mode.
I don't know if there are other better solutions or if I am using it wrong.
Reproduction
https://github.com/daoerche/polyfills-legacy-error-demo
System Info
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: