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

polyfill-regenerator pollutes global scope even if set to "usage-pure" #59

Open
utrolig opened this issue Feb 8, 2021 · 9 comments
Open

Comments

@utrolig
Copy link

utrolig commented Feb 8, 2021

I might be misunderstanding here, but I thought using polyfill-regenerator was not supposed to pollute global scope if set to usage-pure. You can see a repro here.

When I build the app and open the index.html file, I can still see the regeneratorRuntime global variable.

@nicolo-ribaudo
Copy link
Member

It's an error on my side, I didn't realize that regenerator always defines the global.

However, this is tracked at facebook/regenerator#302.

@stiboost
Copy link

stiboost commented Feb 8, 2021

Thanks for the fast response - does this mean that we would have to wait until it is resolved in the issue you linked, or are you able to resolve it?

@nicolo-ribaudo
Copy link
Member

This needs to be fixed in regenerator itself, since currently it doesn't expose an entry point which exports regeneratorRuntime without also defining it as a global.

@utrolig
Copy link
Author

utrolig commented Feb 8, 2021

So there is no way to completely polyfill and transpile the code down without requiring the regeneratorRuntime ?

@nicolo-ribaudo
Copy link
Member

without requiring the regeneratorRuntime ?

I'm not 100% sure I understand what you are asking. If you look at your dist/bundle.js file, it never uses the regeneratorRuntime global variable.
It defines it (regeneratorRuntime=r, which is the same as window.regeneratorRuntime=r), but then never relies on it.

@utrolig
Copy link
Author

utrolig commented Feb 8, 2021

Sorry I should've been more specific.

What I'm trying to achieve is to transpile my typescript application with async/await down to IE11 compatible code, without polluting the global scope. That includes polyfilling without scope pollution as well. There doesn't seem to be too much information about that on the web in general

@nicolo-ribaudo
Copy link
Member

Thanks for clarifying.

Then the answer is "it's not possible until regenerator-runtime stops polluting the global scope (facebook/regenerator#302). When it stops doing so, this plugin won't need any change but you'll just need to update your regenerator-runtime dependency."

@juergba
Copy link

juergba commented Aug 4, 2021

A new version v0.13.9 of regenerator-runtime has been released recently, including this commit.
Does it solve this issue?

@ljharb
Copy link
Member

ljharb commented Aug 4, 2021

That commit would only impact CSP, not global scope.

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

5 participants