regenerator
regenerator copied to clipboard
feat: make it strict mode & CSP compatible if possible
Use well-known global names if possible
@benjamn hi, can you review this? this is a small PR
@benjamn hi, can you review this? this is a small PR |
@Jack-Works What do you think about this alternate approach? https://github.com/facebook/regenerator/issues/378#issuecomment-764878050
@Jack-Works What do you think about this alternate approach? #378 (comment)
@benjamn hi that's a cool trick but in some environment like moddable (a JS engine for embedded env) the Object.prototype
is frozen. You cannot add things to it. Please at least leave the globalThis
try.
I'd recommend using all of globalThis
, self
, and global
before resorting to a monkey patch on Object.prototype
.
I have a sneaking suspicion that it will cause a massive deoptimization is everything but the newest browsers. The delete
is going to turn the Object.prototype
into map-mode, which will slow down every single object access. All of them, everywhere, and everything inherits from Object.prototype
.
I'm proposing it as the most stable and tested way one more time: https://github.com/zloirock/core-js/blob/v3.8.3/packages/core-js/internals/global.js
Has this PR stalled? Would love to see it go in for those of us tring to build things in CSP environments.
I'm just waiting for the maintainer to respond. There aren't so many things I need to up-to-date with.
@Jack-Works This PR will fail Content Security Policy, please check the better way that @zloirock has linked in previous comment.
@Jack-Works This PR will fail Content Security Policy, please check the better way that @zloirock has linked in previous comment.
The original version also violates CSP. I'm making it better on modern browser to use globalThis directly so it don't have to violate CSP
I have rebased to master to resolve merge conflicts.
@Jack-Works This PR will fail Content Security Policy, please check the better way that @zloirock has linked in previous comment.
Updated
Is this issue still relevant? Or is it fixed in regenerator-runtime v.0.13.9? Thank you
It's fixed only for engines with globalThis
.
I keep snoozing this tab "Until next month", hoping every time it re-appears that the PR will have been merged. This really seems like a good fix for the described issue, in addition to being backwards-compatible.
On a side note, I can't remember ever actually have gotten very pissed off when debugging, but when I was debugging the strange CSP issue I had almost a year ago, and finally finding out the reason things were failing, the snarky comment that this PR thankfully removes - certainly had me swearing.
Anyhow, I'm crossing my fingers this will be fixed in January! :)
I tried as many names as possible. Not only globalThis
now.