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

Inject polyfills via webpack provide (not modifying global env) #1881

Merged
merged 3 commits into from
Aug 16, 2018

Conversation

tchakabam
Copy link
Collaborator

@tchakabam tchakabam commented Aug 15, 2018

This PR will...

  • Make the Number.isFinite polyfill be injected in local scopes where it is used (or where Number is used in fact)
  • The polyfill adresses Number as a whole (but that is just a conceptual detail, doesn't change the result)
  • Remove the String endsWith polyfill that was modifying globals (we don't need it anywhere)

Why is this Pull Request needed?

We don't want to touch global env with our bundle

Are there any points in the code the reviewer needs to double check?

Resolves issues:

Checklist

  • changes have been done against master branch, and PR does not conflict
  • new unit / functional tests have been added (whenever applicable)
  • API or design changes are documented in API.md

@tjenkinson
Copy link
Member

@friday mentioned here that we could probably also remove getSelfScope() and just replace window with self everywhere. maybe a different PR

@tchakabam
Copy link
Collaborator Author

@tjenkinson yes, he is probably right :) we should put that on our todo-list. but i might also be able to address it here tomorrow, should be quick. thanks for the review!

@tchakabam
Copy link
Collaborator Author

about the get-self-scope, i'd like to discuss first with others so we agree on an approach that will work long-term, and we could also use the webpack provide-plugin there, tbd, one thing after another :)

@tchakabam tchakabam merged commit 998fb9b into master Aug 16, 2018
@friday
Copy link
Contributor

friday commented Aug 16, 2018

Regarding replacing getSelfScope():

I think a reasonable approach would be to make sure the eslint environment is browser for files which are never run as web workers and worker for the web worker ones (see https://eslint.org/docs/user-guide/configuring#specifying-environments). Then use window or self correspondingly. That way, using window in the worker environment (only) should result in an eslint error.

People are used to window, and it may be taxing for you as maintainers to have to explain why people should use self everywhere.

However, if the web worker files are importing many other dependencies this may be complex to handle. You would know this better than me.

@tchakabam tchakabam deleted the feature/ponyfill-the-polyfills branch November 20, 2018 14:54
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

Successfully merging this pull request may close these issues.

3 participants