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

Simplify web worker registry to reduce bundle size #11511

Merged
merged 3 commits into from
Feb 16, 2022

Conversation

mourner
Copy link
Member

@mourner mourner commented Feb 15, 2022

The web worker class registry register function previously accepted a class name, introduced in #5804. Since then, a lot has changed, including switch to ES / Rollup and dropping both IE11 & ES5 transpilation, so classes are now first-class citizen and we can rely on their name property.

The class names we specified for register were strings scattered across the codebase that didn't get minified and no longer served any purpose. Getting rid of them (and having asserts to make sure classes have names and we register those that are transferred) lands us a free -566 bytes gzipped bundle reduction.

Note that I also removed shallow option which was unused since its introduction, and had to adjust Flow handling in one unrelated part of code (no idea why Flow started complaining where it was silent before, probably a bug).

Launch Checklist

  • briefly describe the changes in this PR
  • write tests for all new functionality
  • manually test the debug page
  • apply changelog label ('bug', 'feature', 'docs', etc) or use the label 'skip changelog'

@mourner mourner added the skip changelog Used for PRs that do not need a changelog entry label Feb 15, 2022
@mourner mourner requested review from ansis and ryanhamley February 15, 2022 10:47
@ansis
Copy link
Contributor

ansis commented Feb 15, 2022

Before this change, could a user choose to transpile even though it wasn't necessary? or was that already broken?

@mourner
Copy link
Member Author

mourner commented Feb 15, 2022

@ansis yes, good point. Transpilation of the final bundle by tools like Babel is already broken due to how it introduces helper functions / classes that are in the top scope and don't get shared between automatic main / worker bundles (same issue as #10565). But in theory, if someone manages to add a transpilation step, it should still work after this PR because of Function.name heuristics like inheriting var name when assigning functions, so name is no longer minified away: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip changelog Used for PRs that do not need a changelog entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants