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

Are you sure that self is web compatible and that adding it to some environments will not break anything? #28

Closed
zloirock opened this issue Sep 8, 2022 · 12 comments

Comments

@zloirock
Copy link

zloirock commented Sep 8, 2022

For example, I'm worried about NodeJS - in some cases, someone detects the environment as NodeJS like typeof self === 'undefined' && typeof process === 'object'.

Related: zloirock/core-js#1118

@ljharb
Copy link
Member

ljharb commented Sep 8, 2022

It's definitely not; we explored this in the globalThis proposal.

@zloirock
Copy link
Author

zloirock commented Sep 8, 2022

@ljharb could you provide the results of this research? For example, here you provide only some links to global and window.

@ljharb
Copy link
Member

ljharb commented Sep 8, 2022

tc39/proposal-global#11 (comment)

There's a number of examples of window and self both implying a browser, such as https://github.com/Microsoft/automatic-graph-layout/blob/ab371280000f4d85eeedc1899e6faaa66ccad009/GraphLayout/MsaglSharpkit/WebMsagl/Msagl/sharpkit_pre.js . In addition, var self = this is too common a pattern for self to be a safe bet.

@zloirock
Copy link
Author

zloirock commented Sep 8, 2022

And here is no self in examples.

@ljharb
Copy link
Member

ljharb commented Sep 8, 2022

"such as" - that was one example. I recall seeing hundreds of them with a trivial github search; you're welcome to do the same.

@zloirock
Copy link
Author

zloirock commented Sep 8, 2022

Just searching something on GitHub - is not proper research. I hope that it was not your motivation at the time of this proposal? After exploring some examples of such code, I found that they are used only on tests or not used at all. However, sure, with a big chance somewhere it's used in some code where it can break something.

@ljharb
Copy link
Member

ljharb commented Sep 8, 2022

If you're aware of another way to do research that isn't fantastically expensive, I'd love to know about it.

@zloirock
Copy link
Author

zloirock commented Sep 8, 2022

I'm awaiting at least some real examples of what it can break. At least some links to GitHub with an explanation. Otherwise, it's just empty words, not "research". I don't think that it's fantastically expensive. I found some tenths of such cases on GitHub for some minutes - but I don't see the danger in any one of them - however, sure, it's not exhaustively - otherwise, this issue wouldn't be here in this form.

@zloirock
Copy link
Author

zloirock commented Sep 8, 2022

However, for NodeJS it's not principal since they can implement it in a new major release - it's not browsers and breaking changes are possible.

@zloirock
Copy link
Author

@jasnell @lucacasonato

@zloirock
Copy link
Author

The final attempt to get feedback, @jasnell @lucacasonato.

@jasnell
Copy link
Contributor

jasnell commented Dec 1, 2022

We've removed self

@jasnell jasnell closed this as completed Dec 1, 2022
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

3 participants